-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
90 lines (80 loc) · 2.49 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
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
import 'package:awesome_datepicker/awesome_datepicker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'constants.dart';
import 'results.dart';
import 'utils.dart';
import 'widgets/glow_text.dart';
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Awesome DatePicker Example App',
home: const Home(),
theme: appTheme,
themeMode: ThemeMode.dark,
);
}
}
class Home extends StatelessWidget {
const Home({super.key});
void _selectBirthdate(BuildContext context) async {
DateTime? selectedDate;
final navigator = Navigator.of(context);
await showAwesomeDatePicker(
context: context,
mode: AwesomeDatePickerMode.hex,
useAlpha: true,
initialDate: DateTime.now(),
pickerHeight: pickerHeight(context),
ringStrokeWidth: ringWidth(context),
onChanged: (date) {
if (kDebugMode) print('changed to $date');
selectedDate = date;
},
);
navigator.pushReplacement(MaterialPageRoute(
builder: (_) => Results(birthdate: selectedDate ?? DateTime.now()),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
borderRadius: BorderRadius.circular(30),
onTap: () => _selectBirthdate(context),
child: Padding(
padding: const EdgeInsets.all(20),
child: GlowText(
style: buttonTextStyle(context),
textAlign: TextAlign.center,
glowColor: primary,
textSpan: const TextSpan(
children: <TextSpan>[
TextSpan(text: "Click here and "),
TextSpan(
text: "select your date of birth",
style: TextStyle(
color: primary,
fontWeight: FontWeight.bold,
inherit: true,
),
),
TextSpan(text: " to\nunlock the secrets of the universe"),
],
),
),
),
),
],
),
),
);
}
}