Very simple image loaded pretty slow with Flutter

I had a similar issue, for me i reduced the the image from 5000 x 5000 to 250 x 250 since they weren't bigger than that in the app files went from 11mb to 75kb, then in Photoshop i also exported it as a smaller file (8 bit) which took it to like 35kb. I would have tried jpeg but i needed the transparent background! but the mass reduction in file size helped me.


I had the same problem with my drawer background image and I solved it with the precache Image, i guess you are using the precacheimage on the wrong place. you need to understand that in order to show the image correctly you need to load the image on app start and not till the state is initiated. try this:

 class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    precacheImage(AssetImage("images/logo_rienpa.png"), context);
    return MaterialApp(
      title: 'Fethi',
      theme: ThemeData(
        primarySwatch: Colors.lightBlue,
      ),
      home: new HomeState(),
    );
  }
}

On the HomeState page you don't need to use didChangeDependencies(), just declare the image on the definition like this :

 ImageProvider logo = AssetImage("images/logo_rienpa.png");

Tags:

Dart

Flutter