@@ -50,99 +50,97 @@ class _MaterialExamplePageState extends State<MaterialExamplePage> {
5050
5151 @override
5252 Widget build (BuildContext context) {
53- return Container (
54- child: Padding (
55- padding: const EdgeInsets .only (right: 8.0 , left: 8.0 ),
56- child: Column (
57- mainAxisAlignment: MainAxisAlignment .center,
58- children: [
59- Padding (
60- padding: const EdgeInsets .only (bottom: 32.0 ),
61- child: Row (
62- mainAxisAlignment: MainAxisAlignment .center,
63- children: [
64- Text (
65- "You've updated this $counter time(s)." ,
66- style: const TextStyle (fontSize: 25 ),
67- ),
68- ],
69- ),
70- ),
71- Row (
53+ return Padding (
54+ padding: const EdgeInsets .only (right: 8.0 , left: 8.0 ),
55+ child: Column (
56+ mainAxisAlignment: MainAxisAlignment .center,
57+ children: [
58+ Padding (
59+ padding: const EdgeInsets .only (bottom: 32.0 ),
60+ child: Row (
7261 mainAxisAlignment: MainAxisAlignment .center,
7362 children: [
7463 Text (
75- DateFormat ('yyyy-MM-dd' ).format (dateTime),
76- style: const TextStyle (fontSize: 30 , fontWeight: FontWeight .bold),
77- ),
78- Text (
79- DateFormat (' kk:mm' ).format (dateTime),
80- style: const TextStyle (fontSize: 30 ),
64+ "You've updated this $counter time(s)." ,
65+ style: const TextStyle (fontSize: 25 ),
8166 ),
8267 ],
8368 ),
84- Padding (
85- padding: const EdgeInsets .only (top: 16.0 ),
86- child: Row (
87- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
88- children: [
89- ElevatedButton (
90- key: materialDateButtonKey,
91- style: ElevatedButton .styleFrom (backgroundColor: Colors .blue.shade300),
92- child: const Text (
93- "Date" ,
94- style: TextStyle (fontSize: 20 ),
95- ),
96- onPressed: () async {
97- final newDate = await pickDate ();
98- if (newDate == null ) return ; // person pressed 'CANCEL'
69+ ),
70+ Row (
71+ mainAxisAlignment: MainAxisAlignment .center,
72+ children: [
73+ Text (
74+ DateFormat ('yyyy-MM-dd' ).format (dateTime),
75+ style: const TextStyle (fontSize: 30 , fontWeight: FontWeight .bold),
76+ ),
77+ Text (
78+ DateFormat (' kk:mm' ).format (dateTime),
79+ style: const TextStyle (fontSize: 30 ),
80+ ),
81+ ],
82+ ),
83+ Padding (
84+ padding: const EdgeInsets .only (top: 16.0 ),
85+ child: Row (
86+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
87+ children: [
88+ ElevatedButton (
89+ key: materialDateButtonKey,
90+ style: ElevatedButton .styleFrom (backgroundColor: Colors .blue.shade300),
91+ child: const Text (
92+ "Date" ,
93+ style: TextStyle (fontSize: 20 ),
94+ ),
95+ onPressed: () async {
96+ final newDate = await pickDate ();
97+ if (newDate == null ) return ; // person pressed 'CANCEL'
9998
100- // Update datetime object that's shown with new date
101- final newDateTime = DateTime (newDate.year, newDate.month, newDate.day, dateTime.hour, dateTime.minute);
102- setState (() {
103- dateTime = newDateTime;
104- counter = counter + 1 ;
105- });
106- }),
107- ElevatedButton (
108- key: materialTimeButtonKey,
109- style: ElevatedButton .styleFrom (backgroundColor: Colors .blue.shade300),
110- child: const Text (
111- "Time" ,
112- style: TextStyle (fontSize: 20 ),
113- ),
114- onPressed: () async {
115- final newTime = await pickTime ();
116- if (newTime == null ) return ; // person pressed 'CANCEL'
99+ // Update datetime object that's shown with new date
100+ final newDateTime = DateTime (newDate.year, newDate.month, newDate.day, dateTime.hour, dateTime.minute);
101+ setState (() {
102+ dateTime = newDateTime;
103+ counter = counter + 1 ;
104+ });
105+ }),
106+ ElevatedButton (
107+ key: materialTimeButtonKey,
108+ style: ElevatedButton .styleFrom (backgroundColor: Colors .blue.shade300),
109+ child: const Text (
110+ "Time" ,
111+ style: TextStyle (fontSize: 20 ),
112+ ),
113+ onPressed: () async {
114+ final newTime = await pickTime ();
115+ if (newTime == null ) return ; // person pressed 'CANCEL'
117116
118- // Update datetime object that's shown with new time
119- final newDateTime = DateTime (dateTime.year, dateTime.month, dateTime.day, newTime.hour, newTime.minute);
120- setState (() {
121- dateTime = newDateTime;
122- counter = counter + 1 ;
123- });
124- })
125- ],
126- ),
117+ // Update datetime object that's shown with new time
118+ final newDateTime = DateTime (dateTime.year, dateTime.month, dateTime.day, newTime.hour, newTime.minute);
119+ setState (() {
120+ dateTime = newDateTime;
121+ counter = counter + 1 ;
122+ });
123+ })
124+ ],
127125 ),
128- Padding (
129- padding : const EdgeInsets . only (top : 16.0 ),
130- child : Row (
131- mainAxisAlignment : MainAxisAlignment .spaceEvenly,
132- children : [
133- ElevatedButton (
134- key : materialDateTimeButtonKey,
135- style : ElevatedButton . styleFrom (backgroundColor : Colors .orange.shade400) ,
136- onPressed : pickDateTime ,
137- child : const Text (
138- "DateTime" ,
139- style : TextStyle (fontSize : 20 ) ,
140- ) ),
141- ] ,
142- ) ,
143- )
144- ],
145- ) ,
126+ ),
127+ Padding (
128+ padding : const EdgeInsets . only (top : 16.0 ),
129+ child : Row (
130+ mainAxisAlignment : MainAxisAlignment .spaceEvenly,
131+ children : [
132+ ElevatedButton (
133+ key : materialDateTimeButtonKey ,
134+ style : ElevatedButton . styleFrom (backgroundColor : Colors .orange.shade400) ,
135+ onPressed : pickDateTime,
136+ child : const Text (
137+ "DateTime" ,
138+ style : TextStyle (fontSize : 20 ),
139+ )) ,
140+ ] ,
141+ ),
142+ )
143+ ] ,
146144 ),
147145 );
148146 }
0 commit comments