rootBundle top-level property
The AssetBundle from which this application was loaded.
The rootBundle contains the resources that were packaged with the
application when it was built. To add resources to the rootBundle for your
application, add them to the
assets subsection of the
flutter section of
name: my_awesome_application flutter: assets: - images/hamilton.jpeg - images/lafayette.jpeg
Rather than using rootBundle directly, consider obtaining the AssetBundle for the current BuildContext using DefaultAssetBundle.of. This layer of indirection lets ancestor widgets substitute a different AssetBundle at runtime (e.g., for testing or localization) rather than directly replying upon the rootBundle created at build time. For convenience, the WidgetsApp or MaterialApp widget at the top of the widget hierarchy configures the DefaultAssetBundle to be the rootBundle.
final AssetBundle rootBundle = _initRootBundle()