νλ¬ν°μμλ μ±μ μ²μ μ€νν λ κ°λ¨νκ² μμ μ΄ μνλ μ΄λ―Έμ§λ₯Ό 보μ¬μ€ μ μλ μ€νλμ ν¨ν€μ§λ₯Ό μ§μνλ€.
https://pub.dev/packages/flutter_native_splash
μ¬μ©λ²μ λ§€μ° κ°λ¨νλ€
pubspec.yaml μ ν¨ν€μ§ μΆκ°
dependencies:
flutter:
sdk: flutter
flutter_native_splash: ^μ΅μ λ²μ # μ€νλμ μ€ν¬λ¦°
flutter_native_splash:
color: "#ffffff" # background color
image: assets/img/high_five.png # μΆκ°ν μ΄λ―Έμ§ νμΌ κ²½λ‘λ₯Ό μΆκ°
κ·Έ ν ν°λ―Έλμ λͺ λ Ήμ΄λ₯Ό μΉλ©΄ μλμΌλ‘ μ€νλμ μ΄λ―Έμ§λ₯Ό μμ±ν΄μ£Όκ³ μ μ©μ΄ μλ£ λλ€.
dart run flutter_native_splash:create
μΆκ°μ μΌλ‘ λκ°μ κ²½μ° μ€νλμ μ΄λ―Έμ§λ₯Ό μνλ μκ°λ§νΌ 보μ¬μ£Όκ³ μΆμλλ° μ΄λ
Future main() async {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
// μ€νλμ νλ©΄μ 보μ¬μ£ΌκΈ° μν΄ 5μ΄κ° λκΈ°
await initialization();
runApp(
const MyApp(),
);
}
Future initialization() async {
await Future.delayed(const Duration(seconds: 3));
FlutterNativeSplash.remove();
}
μμ κ°μ΄ μ΄κΈ°νν λ Durationμ μ£Όμ΄μ ν΄κ²°νμλ€.
λ¬Όλ‘ λ λμ λ°©λ²λ μκ² μ§λ§ λ°λ‘ μ€νλμμ μκ°μ κΈΈκ² λ§λ€μ΄μ£Όλ λ΄μ₯κΈ°λ₯μ μμκΈ°μ μ΄λ κ² μμ±νμλ€.