From 6dc440bdfde897bdb6dcc3603597ce983aa972b0 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Tue, 19 Apr 2016 11:19:38 -0700 Subject: [PATCH] Make rootBundle handle the no-mojo case. (#3408) The defaulting logic for bundles really belongs in the services layer, not the widgets layer. This way we can tell non-widget code just to use rootBundle if it just wants to read a JSON file or some such. --- packages/flutter/lib/src/services/asset_bundle.dart | 2 +- packages/flutter/lib/src/widgets/app.dart | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index 18e6674c85..20041fddca 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -106,7 +106,7 @@ class MojoAssetBundle extends CachingAssetBundle { AssetBundle _initRootBundle() { int h = ui.MojoServices.takeRootBundle(); if (h == core.MojoHandle.INVALID) - return null; + return new NetworkAssetBundle(Uri.base); core.MojoHandle handle = new core.MojoHandle(h); return new MojoAssetBundle(new AssetBundleProxy.fromHandle(handle)); } diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 92b945b78a..2a4284a2d3 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -20,14 +20,6 @@ import 'performance_overlay.dart'; import 'semantics_debugger.dart'; import 'title.dart'; -AssetBundle _initDefaultBundle() { - if (rootBundle != null) - return rootBundle; - return new NetworkAssetBundle(Uri.base); -} - -final AssetBundle _defaultBundle = _initDefaultBundle(); - typedef Future LocaleChangedCallback(Locale locale); /// A convenience class that wraps a number of widgets that are commonly @@ -173,7 +165,7 @@ class WidgetsAppState extends State implements BindingO child: new LocaleQuery( data: _localeData, child: new AssetVendor( - bundle: _defaultBundle, + bundle: rootBundle, devicePixelRatio: ui.window.devicePixelRatio, child: new Title( title: config.title,