Search code examples
flutter

remove default splash screen android & ios flutter


i preferred use custom splash screen that's allow me to build whole page . so , am trying to remove default splash from android and ios

void main() async {
  flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  runApp(MaterialApp(
    title: 'Navigation Basics',
    debugShowCheckedModeBanner: false,
    home: new SplashPage(),
    routes: {
      // When navigating to the "/" route, build the FirstScreen widget.
      '/home': (BuildContext context) => new FirstRoute(),
    },
  ));
}

class SplashPage extends StatefulWidget {
  @override
  SplashPageState createState() => SplashPageState();
}

class SplashPageState extends State<SplashPage> {

  void navigationToNextPage() {
    Navigator.pushNamed(context, '/home');
  }

  startSplashScreenTimer() async {
    var _duration = new Duration(seconds: 5);
    return new Timer(_duration, navigationToNextPage);
  }

  @override
  void initState() {
    super.initState();
    startSplashScreenTimer();
  }

  @override
  Widget build(BuildContext context) {

    SystemChrome.setEnabledSystemUIOverlays([]);

    return Container(
        child: new Image.asset('images/banner.png', fit: BoxFit.fill));
  }
}

so i need to remove default splash screen from both with flutter


Solution

  • The default splash screen cannot be overridden with Dart/Flutter alone. They are controls shown by the native Android/iOS context while the Flutter runtime is initializing. As such, any splash screen widget you create inside Flutter will show after the default splash screen. (Even if you completely remove the default splash image, the app would just be a blank while screen until Flutter finished loading, and that's bad design.)

    There are instructions on how to change the default splash screen here. If you are well-versed in native Android or iOS development, you could take it a step further than just a simple image if you wanted.