Skip to content

Commit 2ac5b34

Browse files
authored
Revert "Refactor initial route code (flutter#19684)" (flutter#20450)
This reverts commit 8d08e6c.
1 parent 5161fd1 commit 2ac5b34

File tree

21 files changed

+133
-353
lines changed

21 files changed

+133
-353
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.
925925
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm
926926
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm
927927
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h
928-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h
929928
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterHeadlessDartRunner.mm
930929
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h
931930
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm

lib/ui/window.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,19 +1056,23 @@ class Window {
10561056
///
10571057
/// ## Android
10581058
///
1059-
/// On Android, the initial route can be set on the [initialRoute](/javadoc/io/flutter/embedding/android/FlutterActivity.NewEngineIntentBuilder.html#initialRoute-java.lang.String-)
1060-
/// method of the [FlutterActivity](/javadoc/io/flutter/embedding/android/FlutterActivity.html)'s
1061-
/// intent builder.
1062-
///
1063-
/// On a standalone engine, see https://flutter.dev/docs/development/add-to-app/android/add-flutter-screen#initial-route-with-a-cached-engine.
1059+
/// On Android, calling
1060+
/// [`FlutterView.setInitialRoute`](/javadoc/io/flutter/view/FlutterView.html#setInitialRoute-java.lang.String-)
1061+
/// will set this value. The value must be set sufficiently early, i.e. before
1062+
/// the [runApp] call is executed in Dart, for this to have any effect on the
1063+
/// framework. The `createFlutterView` method in your `FlutterActivity`
1064+
/// subclass is a suitable time to set the value. The application's
1065+
/// `AndroidManifest.xml` file must also be updated to have a suitable
1066+
/// [`<intent-filter>`](https://developer.android.com/guide/topics/manifest/intent-filter-element.html).
10641067
///
10651068
/// ## iOS
10661069
///
1067-
/// On iOS, the initial route can be set on the `initialRoute`
1068-
/// parameter of the [FlutterViewController](/objcdoc/Classes/FlutterViewController.html)'s
1069-
/// initializer.
1070-
///
1071-
/// On a standalone engine, see https://flutter.dev/docs/development/add-to-app/ios/add-flutter-screen#route.
1070+
/// On iOS, calling
1071+
/// [`FlutterViewController.setInitialRoute`](/objcdoc/Classes/FlutterViewController.html#/c:objc%28cs%29FlutterViewController%28im%29setInitialRoute:)
1072+
/// will set this value. The value must be set sufficiently early, i.e. before
1073+
/// the [runApp] call is executed in Dart, for this to have any effect on the
1074+
/// framework. The `application:didFinishLaunchingWithOptions:` method is a
1075+
/// suitable time to set this value.
10721076
///
10731077
/// See also:
10741078
///

lib/web_ui/lib/src/ui/window.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,26 @@ abstract class Window {
710710
///
711711
/// This will be the string "`/`" if no particular route was requested.
712712
///
713+
/// ## Android
714+
///
715+
/// On Android, calling
716+
/// [`FlutterView.setInitialRoute`](/javadoc/io/flutter/view/FlutterView.html#setInitialRoute-java.lang.String-)
717+
/// will set this value. The value must be set sufficiently early, i.e. before
718+
/// the [runApp] call is executed in Dart, for this to have any effect on the
719+
/// framework. The `createFlutterView` method in your `FlutterActivity`
720+
/// subclass is a suitable time to set the value. The application's
721+
/// `AndroidManifest.xml` file must also be updated to have a suitable
722+
/// [`<intent-filter>`](https://developer.android.com/guide/topics/manifest/intent-filter-element.html).
723+
///
724+
/// ## iOS
725+
///
726+
/// On iOS, calling
727+
/// [`FlutterViewController.setInitialRoute`](/objcdoc/Classes/FlutterViewController.html#/c:objc%28cs%29FlutterViewController%28im%29setInitialRoute:)
728+
/// will set this value. The value must be set sufficiently early, i.e. before
729+
/// the [runApp] call is executed in Dart, for this to have any effect on the
730+
/// framework. The `application:didFinishLaunchingWithOptions:` method is a
731+
/// suitable time to set this value.
732+
///
713733
/// See also:
714734
///
715735
/// * [Navigator], a widget that handles routing.

shell/platform/darwin/ios/framework/Headers/Flutter.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,52 @@
55
#ifndef FLUTTER_FLUTTER_H_
66
#define FLUTTER_FLUTTER_H_
77

8+
/**
9+
BREAKING CHANGES:
10+
11+
December 17, 2018:
12+
- Changed designated initializer on FlutterEngine
13+
14+
October 5, 2018:
15+
- Removed FlutterNavigationController.h/.mm
16+
- Changed return signature of `FlutterDartHeadlessCodeRunner.run*` from void
17+
to bool
18+
- Removed HeadlessPlatformViewIOS
19+
- Marked FlutterDartHeadlessCodeRunner deprecated
20+
21+
August 31, 2018: Marked -[FlutterDartProject
22+
initFromDefaultSourceForConfiguration] and FlutterStandardBigInteger as
23+
unavailable.
24+
25+
July 26, 2018: Marked -[FlutterDartProject
26+
initFromDefaultSourceForConfiguration] deprecated.
27+
28+
February 28, 2018: Removed "initWithFLXArchive" and
29+
"initWithFLXArchiveWithScriptSnapshot".
30+
31+
January 15, 2018: Marked "initWithFLXArchive" and
32+
"initWithFLXArchiveWithScriptSnapshot" as unavailable following the
33+
deprecation from December 11, 2017. Scheduled to be removed on February
34+
19, 2018.
35+
36+
January 09, 2018: Deprecated "FlutterStandardBigInteger" and its use in
37+
"FlutterStandardMessageCodec" and "FlutterStandardMethodCodec". Scheduled to
38+
be marked as unavailable once the deprecation has been available on the
39+
flutter/flutter alpha branch for four weeks. "FlutterStandardBigInteger" was
40+
needed because the Dart 1.0 int type had no size limit. With Dart 2.0, the
41+
int type is a fixed-size, 64-bit signed integer. If you need to communicate
42+
larger integers, use NSString encoding instead.
43+
44+
December 11, 2017: Deprecated "initWithFLXArchive" and
45+
"initWithFLXArchiveWithScriptSnapshot" and scheculed the same to be marked as
46+
unavailable on January 15, 2018. Instead, "initWithFlutterAssets" and
47+
"initWithFlutterAssetsWithScriptSnapshot" should be used. The reason for this
48+
change is that the FLX archive will be deprecated and replaced with a flutter
49+
assets directory containing the same files as the FLX did.
50+
51+
November 29, 2017: Added a BREAKING CHANGES section.
52+
*/
53+
854
#include "FlutterAppDelegate.h"
955
#include "FlutterBinaryMessenger.h"
1056
#include "FlutterCallbackCache.h"

shell/platform/darwin/ios/framework/Headers/FlutterEngine.h

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
2424
*/
2525
extern NSString* const FlutterDefaultDartEntrypoint;
2626

27-
/**
28-
* The default Flutter initial route ("/").
29-
*/
30-
extern NSString* const FlutterDefaultInitialRoute;
31-
3227
/**
3328
* The FlutterEngine class coordinates a single instance of execution for a
3429
* `FlutterDartProject`. It may have zero or one `FlutterViewController` at a
@@ -58,24 +53,6 @@ extern NSString* const FlutterDefaultInitialRoute;
5853
FLUTTER_EXPORT
5954
@interface FlutterEngine : NSObject <FlutterTextureRegistry, FlutterPluginRegistry>
6055

61-
/**
62-
* Default initializer for a FlutterEngine.
63-
*
64-
* Threads created by this FlutterEngine will appear as "FlutterEngine #" in
65-
* Instruments. The prefix can be customized using `initWithName`.
66-
*
67-
* The engine will execute the project located in the bundle with the identifier
68-
* "io.flutter.flutter.app" (the default for Flutter projects).
69-
*
70-
* A newly initialized engine will not run until either `-runWithEntrypoint:` or
71-
* `-runWithEntrypoint:libraryURI:` is called.
72-
*
73-
* FlutterEngine created with this method will have allowHeadlessExecution set to `YES`.
74-
* This means that the engine will continue to run regardless of whether a `FlutterViewController`
75-
* is attached to it or not, until `-destroyContext:` is called or the process finishes.
76-
*/
77-
- (instancetype)init;
78-
7956
/**
8057
* Initialize this FlutterEngine.
8158
*
@@ -137,12 +114,17 @@ FLUTTER_EXPORT
137114
project:(nullable FlutterDartProject*)project
138115
allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;
139116

117+
/**
118+
* The default initializer is not available for this object.
119+
* Callers must use `-[FlutterEngine initWithName:project:]`.
120+
*/
121+
- (instancetype)init NS_UNAVAILABLE;
122+
140123
+ (instancetype)new NS_UNAVAILABLE;
141124

142125
/**
143126
* Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
144-
* contains `main()`), using `main()` as the entrypoint (the default for Flutter projects),
145-
* and using "/" (the default route) as the initial route.
127+
* contains `main()`), using `main()` as the entrypoint (the default for Flutter projects).
146128
*
147129
* The first call to this method will create a new Isolate. Subsequent calls will return
148130
* immediately and have no effect.
@@ -153,7 +135,7 @@ FLUTTER_EXPORT
153135

154136
/**
155137
* Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
156-
* contains `main()`), using "/" (the default route) as the initial route.
138+
* contains `main()`).
157139
*
158140
* The first call to this method will create a new Isolate. Subsequent calls will return
159141
* immediately and have no effect.
@@ -167,25 +149,6 @@ FLUTTER_EXPORT
167149
*/
168150
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;
169151

170-
/**
171-
* Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
172-
* contains `main()`).
173-
*
174-
* The first call to this method will create a new Isolate. Subsequent calls will return
175-
* immediately and have no effect.
176-
*
177-
* @param entrypoint The name of a top-level function from the same Dart
178-
* library that contains the app's main() function. If this is FlutterDefaultDartEntrypoint (or
179-
* nil), it will default to `main()`. If it is not the app's main() function, that function must
180-
* be decorated with `@pragma(vm:entry-point)` to ensure the method is not tree-shaken by the Dart
181-
* compiler.
182-
* @param initialRoute The name of the initial Flutter `Navigator` `Route` to load. If this is
183-
* FlutterDefaultInitialRoute (or nil), it will default to the "/" route.
184-
* @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
185-
*/
186-
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint
187-
initialRoute:(nullable NSString*)initialRoute;
188-
189152
/**
190153
* Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
191154
* which may not be the same as the library containing the Dart program's `main()` function.

shell/platform/darwin/ios/framework/Headers/FlutterViewController.h

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ FLUTTER_EXPORT
5555
*
5656
* The initialized viewcontroller will attach itself to the engine as part of this process.
5757
*
58-
* @param engine The `FlutterEngine` instance to attach to. Cannot be nil.
58+
* @param engine The `FlutterEngine` instance to attach to.
5959
* @param nibName The NIB name to initialize this UIViewController with.
6060
* @param nibBundle The NIB bundle.
6161
*/
@@ -78,23 +78,6 @@ FLUTTER_EXPORT
7878
nibName:(nullable NSString*)nibName
7979
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
8080

81-
/**
82-
* Initializes a new FlutterViewController and `FlutterEngine` with the specified
83-
* `FlutterDartProject` and `initialRoute`.
84-
*
85-
* This will implicitly create a new `FlutterEngine` which is retrievable via the `engine` property
86-
* after initialization.
87-
*
88-
* @param project The `FlutterDartProject` to initialize the `FlutterEngine` with.
89-
* @param initialRoute The initial `Navigator` route to load.
90-
* @param nibName The NIB name to initialize this UIViewController with.
91-
* @param nibBundle The NIB bundle.
92-
*/
93-
- (instancetype)initWithProject:(nullable FlutterDartProject*)project
94-
initialRoute:(nullable NSString*)initialRoute
95-
nibName:(nullable NSString*)nibName
96-
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
97-
9881
/**
9982
* Initializer that is called from loading a FlutterViewController from a XIB.
10083
*
@@ -134,8 +117,6 @@ FLUTTER_EXPORT
134117
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
135118

136119
/**
137-
* Deprecated API to set initial route.
138-
*
139120
* Attempts to set the first route that the Flutter app shows if the Flutter
140121
* runtime hasn't yet started. The default is "/".
141122
*
@@ -146,15 +127,9 @@ FLUTTER_EXPORT
146127
* Setting this after the Flutter started running has no effect. See `pushRoute`
147128
* and `popRoute` to change the route after Flutter started running.
148129
*
149-
* This is deprecated because it needs to be called at the time of initialization
150-
* and thus should just be in the `initWithProject` initializer. If using
151-
* `initWithEngine`, the initial route should be set on the engine's
152-
* initializer.
153-
*
154130
* @param route The name of the first route to show.
155131
*/
156-
- (void)setInitialRoute:(NSString*)route
157-
FLUTTER_DEPRECATED("Use FlutterViewController initializer to specify initial route");
132+
- (void)setInitialRoute:(NSString*)route;
158133

159134
/**
160135
* Instructs the Flutter Navigator (if any) to go back.
@@ -163,7 +138,8 @@ FLUTTER_EXPORT
163138

164139
/**
165140
* Instructs the Flutter Navigator (if any) to push a route on to the navigation
166-
* stack.
141+
* stack. The setInitialRoute method should be preferred if this is called before the
142+
* FlutterViewController has come into view.
167143
*
168144
* @param route The name of the route to push to the navigation stack.
169145
*/

0 commit comments

Comments
 (0)