To remove the default splash screen in Flutter, you need to perform the following steps:
-
Open the
pubspec.yaml
file of your Flutter project. -
Under the
flutter
section, specify the assets you want to show as your splash screen. For example:flutter: assets: - assets/images/splash.png
-
Inside the
lib
folder, create a new folder calledutils
(or any other appropriate name) and create a new Dart file inside it, for example,splash_screen.dart
. -
In the
splash_screen.dart
file, import the required packages:import 'package:flutter/material.dart'; import 'package:flutter/services.dart';
-
Create a new class called
SplashScreen
that extendsStatelessWidget
:class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/splash.png'), fit: BoxFit.cover, ), ), ), ); } }
-
In the main
lib
folder, open themain.dart
file and replace the existingMyApp
class with the following:class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]); return MaterialApp( title: 'Your App', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: SplashScreen(), // Replace this with your app's home screen widget ); } }
- Run your Flutter app, and the specified image will be displayed as the splash screen before transitioning to your app’s home screen.
Make sure to update the path and asset name in the steps above to match your actual asset folder structure and file name.
- How to create multiple tables in sqlite android studio
- How to change namespace in c# visual studio
- How to install detectron2 on windows
- How to delete selected row from gridview and database in c#
- How to modify request body before reaching controller in spring boot
- How to convert datarow to datatable in c#
- How to expire jwt token on logout in node js
- How to change json property name dynamically in java
- How to refresh futurebuilder flutter