-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.dart
executable file
·53 lines (46 loc) · 1.18 KB
/
main.dart
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
import 'package:flutter/material.dart';
import 'package:after_init/after_init.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: Example(),
),
),
);
}
class Example extends StatefulWidget {
@override
_ExampleState createState() => _ExampleState();
}
class _ExampleState extends State<Example> with AfterInitMixin<Example> {
late Size size;
/// This gets called first, as usual.
@override
void initState() {
super.initState();
// Your code here
}
/// This gets called after initState(), only once.
/// Safely access inherited widgets here.
@override
void didInitState() {
// No need to call super.didInitState().
// setState() is not required because build() will automatically be called by Flutter.
size = MediaQuery.of(context).size;
}
/// This gets called after didInitState().
/// And anytime the widget's dependencies change, as usual.
@override
void didChangeDependencies() {
super.didChangeDependencies();
// Your code here
}
/// Finally this gets called, as usual.
@override
Widget build(BuildContext context) {
return Center(
child: Text(size.toString()),
);
}
}