Can you resize an image in a flutter_native_splash?

Issue

I am using the package mentioned in the title, but I do not have expected results.
enter image description here

As you can see, the image does not occupy all the space. and here the .yaml file

flutter_native_splash: 
  color: 00ff00
  image: assets/splash_screenrick.png

By the way, I use the color because if I delete it, it marks an error.

Solution

This should be what you are looking for:

Future<void> main() async {
  // Show splash screen for 2 seconds
  runApp(
    SizedBox(
      child: Image.asset(
        'assets/image1.jpg',
        fit: BoxFit.cover,
      ),
    ),
  );
  await Future.delayed(const Duration(seconds: 2));
  // Then, start the app
  runApp(const MyApp());
}

Without any package. This also helps for when you have a splash screen with animations.

Answered By – davidn

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published