forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Move web-only initialization APIs to
dart:ui_web
(flutter#43111)
| Old API in `dart:ui` | New API in `dart:ui_web` | |-|-| | ~`webOnlyInitializePlatform`~ | ~`ui_web.initializePlatform`~ | | `webOnlyWarmupEngine` | `ui_web.bootstrapEngine` | | `debugEmulateFlutterTesterEnvironment` | `ui_web.debugEmulateFlutterTesterEnvironment` | | `webOnlySetPluginHandler` | `ui_web.setPluginHandler` | Part of flutter/flutter#126831
- Loading branch information
Showing
26 changed files
with
214 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:ui/src/engine.dart'; | ||
import 'package:ui/ui.dart' as ui; | ||
|
||
/// Bootstraps the Flutter Web engine and app. | ||
/// | ||
/// If the app uses plugins, then the [registerPlugins] callback can be provided | ||
/// to register those plugins. This is done typically by calling | ||
/// `registerPlugins` from the auto-generated `web_plugin_registrant.dart` file. | ||
/// | ||
/// The [runApp] callback is invoked to run the app after the engine is fully | ||
/// initialized. | ||
/// | ||
/// For more information, see what the `flutter_tools` does in the entrypoint | ||
/// that it generates around the app's main method: | ||
/// | ||
/// * https://github.com/flutter/flutter/blob/95be76ab7e3dca2def54454313e97f94f4ac4582/packages/flutter_tools/lib/src/web/file_generators/main_dart.dart#L14-L43 | ||
/// | ||
/// By default, engine initialization and app startup occur immediately and back | ||
/// to back. They can be programmatically controlled by setting | ||
/// `FlutterLoader.didCreateEngineInitializer`. For more information, see how | ||
/// `flutter.js` does it: | ||
/// | ||
/// * https://github.com/flutter/flutter/blob/95be76ab7e3dca2def54454313e97f94f4ac4582/packages/flutter_tools/lib/src/web/file_generators/js/flutter.js | ||
Future<void> bootstrapEngine({ | ||
ui.VoidCallback? registerPlugins, | ||
ui.VoidCallback? runApp, | ||
}) async { | ||
// Create the object that knows how to bootstrap an app from JS and Dart. | ||
final AppBootstrap bootstrap = AppBootstrap( | ||
initializeEngine: ([JsFlutterConfiguration? configuration]) async { | ||
await initializeEngineServices(jsConfiguration: configuration); | ||
}, runApp: () async { | ||
if (registerPlugins != null) { | ||
registerPlugins(); | ||
} | ||
await initializeEngineUi(); | ||
if (runApp != null) { | ||
runApp(); | ||
} | ||
}, | ||
); | ||
|
||
final FlutterLoader? loader = flutter?.loader; | ||
if (loader == null || loader.isAutoStart) { | ||
// The user does not want control of the app, bootstrap immediately. | ||
domWindow.console.debug('Flutter Web Bootstrap: Auto.'); | ||
await bootstrap.autoStart(); | ||
} else { | ||
// Yield control of the bootstrap procedure to the user. | ||
domWindow.console.debug('Flutter Web Bootstrap: Programmatic.'); | ||
loader.didCreateEngineInitializer(bootstrap.prepareEngineInitializer()); | ||
} | ||
} |
Oops, something went wrong.