Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove default splash screen android & ios flutter

Tags:

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

like image 731
Mikel Tawfik Avatar asked Dec 23 '22 21:12

Mikel Tawfik


2 Answers

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.

like image 195
Abion47 Avatar answered Jan 22 '23 12:01

Abion47


You can do it by ignoring adding a launcher icon.

In android go to app -> main -> res -> drawable -> launch_background.xml and leave it like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />    
    <!-- <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
    </item> -->
</layer-list>
like image 27
Ashnet Avatar answered Jan 22 '23 11:01

Ashnet