본문 바로가기
프로그래밍/Flutter-Dart

[Flutter] Splash 화면

by 채연2 2022. 3. 8.

pubspec.yaml

dependencies:
  flutter_native_splash: ^1.1.8+4

 

 

projet_name\flutter_native_splash.yaml 생성

flutter_native_splash:
  image: assets/images/logo.png
  fullscreen: true

 

 

패키지 실행 (cmd 창)

flutter pub run flutter_native_splash:create

 

 

splash.dart

class Splash extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Image.asset(
            "assets/images/logo.png"
        ),
      ),
    );
  }
}

 

 

 

main.dart

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: Future.delayed(Duration(seconds: 3)),
      builder: (context, AsyncSnapshot snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return MaterialApp(debugShowCheckedModeBanner: false, home: Splash());
        } else {
          return MaterialApp(
            debugShowCheckedModeBanner: false,
            home: Container(),
          );
        }
      },
    );
  }
}

 

 

320x100

댓글