-
-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathsplash_screen.dart
More file actions
56 lines (50 loc) · 1.49 KB
/
splash_screen.dart
File metadata and controls
56 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:lottie/lottie.dart';
// This example show how to use a Lottie animation as a SplashScreen for your application
// Since animation are loaded from the assets and can take a few milliseconds to
// load, we instruct flutter to defer the first frame until when the animation
// is actually ready to be displayed.
void main() async {
Logger.root
..level = Level.ALL
..onRecord.listen(print);
runApp(const SplashScreen());
}
class SplashScreen extends StatefulWidget {
const SplashScreen({Key? key}) : super(key: key);
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen>
with TickerProviderStateMixin {
@override
void initState() {
super.initState();
WidgetsBinding.instance!.deferFirstFrame();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.lightBlue,
home: Scaffold(
backgroundColor: Colors.lightBlue,
appBar: AppBar(
title: const Text('Splash screen'),
),
body: SingleChildScrollView(
child: Center(
child: Column(
children: [
Lottie.asset('assets/AndroidWave.json',
onLoaded: (composition) {
WidgetsBinding.instance!.allowFirstFrame();
}),
],
),
),
),
),
);
}
}