'precachePicture throwing null exception when using in main.dart
I am using svg in my onboarding screen and I want to precache it as it takes time for svg to load. But whenever I am trying to precache, I'm getting an exception.
════════ Exception caught by SVG ═══════════════════════════════════════════════
The following _CastError was thrown resolving a single-frame picture stream:
Null check operator used on a null value
My main.dart code:
Future.wait(
[
precachePicture(
ExactAssetPicture(
SvgPicture.svgStringDecoderBuilder, 'assets/shopping.svg'),
null,
),
],
);
runApp(
MaterialApp(
initialRoute: "welcome_screen",
debugShowCheckedModeBanner: false,
routes: {
"signup": (context) => const SignUp(),
"signin": (context) => const SignIn(),
"welcome_screen": (context) => const WelcomeScreen(),
},
),
);
I want to use the svg on WelcomeScreen().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|