/
counter.dart
96 lines (88 loc) · 2.48 KB
/
counter.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
void _incrementCounter() {
setState(() {
_counter = _counter + 7;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
backgroundColor: Colors.pink.shade50,
appBar: AppBar(
centerTitle: true,
toolbarHeight: 100,
leading: IconButton(icon: const Icon(Icons.menu), onPressed: () {}),
title: Text(widget.title),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.elliptical(
MediaQuery.of(context).size.shortestSide, 56.0),
),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'You loved attending',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w800,
color: Colors.cyan,
),
),
const Text(
'Flutter in Focus',
style: TextStyle(
color: Colors.blue,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.cyan,
foregroundColor: Colors.black,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(16.0))),
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.satellite_rounded),
),
);
}
}