fayaz07/animated_splash
Flutter 앱용 가벼운 패키지로, 아름다운 페이드 애니메이션을 사용하여 스플래시 화면을 쉽게 표시할 수 있습니다.
- Stars
- 112
- Forks
- 25
- 최근 푸시(UTC)
- 2021. 7. 3.
- 프로젝트 상태
- 보관됨
기술 주제
사용 중인 의존성
의존성 목록 2 개
- flutter
{"sdk":"flutter"} - flutter_test개발 의존성
{"sdk":"flutter"}
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
README 펼치기 / 접기
Animated Splash Screen
Using the package
environment:
sdk: ">=2.1.0 <3.0.0"
Add dependency in pubspec.yaml
dependencies:
animated_splash: ^1.0.0
Things to do
- Get a logo for your app
- Prepare what to execute while the splash screen is shown (initializing your db, shared preferences, firebase...etc)
- Screen to be shown after splash screen and background process
- Duration of Splash Screen
Import the package
import 'package:animated_splash/animated_splash.dart';
Show splash screen for some duration
type: AnimatedSplashType.StaticDuration
Inside your main function, use home as SplashScreen(_), the parameters are as follows:
imagePath: Path to your app-logo/image home: Screen to be shown after splash duration: duration of splash screen in milliseconds type
runApp(MaterialApp(
home: AnimatedSplash(
imagePath: 'assets/flutter_icon.png',
home: Home(),
duration: 2500,
type: AnimatedSplashType.StaticDuration,
),
));
Execute a function in background and based on the value from that function navigate to different screen
type: AnimatedSplashType.BackgroundProcess
Create an object of Function that gets executed while splash screen is shown
Function duringSplash = () {
//Write your code here
...
return value;
};
Create routes according to your function return value
//setup the return value correctly for proper navigation
Map<dynamic, Widget> returnValueAndHomeScreen = {1: Home(), 2: HomeSt()};
Inside your main function, use home as SplashScreen(_), the parameters are as follows:
imagePath: Path to your app-logo/image home: Screen to be shown after splash customFunction: the function you have written above duration: duration of splash screen in milliseconds type output value of customFunction and home screen to navigate(Map function)
runApp(MaterialApp(
home: AnimatedSplash(
imagePath: 'assets/flutter_icon.png',
home: Home(),
customFunction: duringSplash,
duration: 2500,
type: AnimatedSplashType.BackgroundProcess,
outputAndHome: op,
),
));