-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support preloadedBundles in WebF (#500)
This PR adds a new preloadedBundles property to the WebF widget, allowing users to preload external resources (HTML, CSS, JavaScript, or Images) before WebF is mounted in Flutter. This feature can save a lot of time if all resources are preloaded before WebF is mounted. Here is a example to use this feature: ```dart Future<List<WebFBundle>> preloadWebFBundles(List<String> entryPoints) async { List<Future<WebFBundle>> bundles = entryPoints.map((e) async { WebFBundle bundle = WebFBundle.fromUrl(e); await bundle.resolve(); await bundle.obtainData(); return bundle; }).toList(); return await Future.wait(bundles); } @OverRide Widget build(BuildContext context) { final MediaQueryData queryData = MediaQuery.of(context); final Size viewportSize = queryData.size; return Scaffold( body: Center( child: Column( children: [ FutureBuilder<List<WebFBundle>>(future: preloadWebFBundles([ // The lists with absolute path for remote resources 'assets:assets/bundle.html', 'assets:assets/bundle.js', 'assets:assets/webf.png', ]), builder: (BuildContext context, AsyncSnapshot<List<WebFBundle>> snapshot) { if (snapshot.data != null) { return WebF( devToolsService: ChromeDevToolsService(), viewportWidth: viewportSize.width - queryData.padding.horizontal, viewportHeight: viewportSize.height - appBar.preferredSize.height - queryData.padding.vertical, preloadedBundles: snapshot.data, bundle: snapshot.data![0] ); } return Text('Load error'); }) ], ), )); } ```
- Loading branch information
Showing
11 changed files
with
113 additions
and
66 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
Oops, something went wrong.