As per the Flutter docs I'm trying to use the DecoratedBox to load a fullscreen image as the background image for a Container.
my pubspec.yaml contains the relevant definition for an embedded asset:
flutter:
uses-material-design: true
assets:
- assets/background.png
and the widget.dart tries to fill the background of a new Container as prescribed:
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
color: Colors.purple,
image : new DecorationImage(
image: new ExactAssetImage('assets/background.png'),
fit: BoxFit.cover,
),
),
),
}
But I get the following error:
Unable to load asset: assets/background.png
Image provider: ExactAssetImage(name: "assets/background.png", scale: 1.0, bundle: null)
Clearly the bundle is not resolving correctly. Does anyone have an idea of what exactly I'm doing wrong here?