Skip to content

Commit 54a47e3

Browse files
committed
fix: Removing warnings. #1
1 parent 16af71f commit 54a47e3

File tree

3 files changed

+166
-171
lines changed

3 files changed

+166
-171
lines changed

lib/cupertino.dart

+84-86
Original file line numberDiff line numberDiff line change
@@ -57,97 +57,95 @@ class _CupertinoExamplePageState extends State<CupertinoExamplePage> {
5757

5858
@override
5959
Widget build(BuildContext context) {
60-
return Container(
61-
child: Padding(
62-
padding: const EdgeInsets.only(right: 8.0, left: 8.0),
63-
child: Column(
64-
mainAxisAlignment: MainAxisAlignment.center,
65-
children: [
66-
Row(
67-
mainAxisAlignment: MainAxisAlignment.center,
60+
return Padding(
61+
padding: const EdgeInsets.only(right: 8.0, left: 8.0),
62+
child: Column(
63+
mainAxisAlignment: MainAxisAlignment.center,
64+
children: [
65+
Row(
66+
mainAxisAlignment: MainAxisAlignment.center,
67+
children: [
68+
Text(
69+
DateFormat('yyyy-MM-dd').format(dateTime),
70+
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
71+
),
72+
Text(
73+
DateFormat(' kk:mm').format(dateTime),
74+
style: const TextStyle(fontSize: 30),
75+
),
76+
],
77+
),
78+
Padding(
79+
padding: const EdgeInsets.only(top: 16.0),
80+
child: Row(
81+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
6882
children: [
69-
Text(
70-
DateFormat('yyyy-MM-dd').format(dateTime),
71-
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
72-
),
73-
Text(
74-
DateFormat(' kk:mm').format(dateTime),
75-
style: const TextStyle(fontSize: 30),
76-
),
83+
ElevatedButton(
84+
key: cupertinoDateButtonKey,
85+
style: ElevatedButton.styleFrom(backgroundColor: Colors.purple.shade300),
86+
onPressed: () => _showDialog(
87+
CupertinoDatePicker(
88+
initialDateTime: dateTime,
89+
mode: CupertinoDatePickerMode.date,
90+
use24hFormat: true,
91+
// This shows day of week alongside day of month
92+
showDayOfWeek: true,
93+
// This is called when the user changes the date.
94+
onDateTimeChanged: (DateTime newDate) {
95+
setState(() => dateTime = newDate);
96+
},
97+
),
98+
),
99+
child: const Text(
100+
"Date",
101+
style: TextStyle(fontSize: 20),
102+
)),
103+
ElevatedButton(
104+
key: cupertinoTimeButtonKey,
105+
style: ElevatedButton.styleFrom(backgroundColor: Colors.purple.shade300),
106+
child: const Text(
107+
"Time",
108+
style: TextStyle(fontSize: 20),
109+
),
110+
onPressed: () => _showDialog(
111+
CupertinoDatePicker(
112+
initialDateTime: dateTime,
113+
mode: CupertinoDatePickerMode.time,
114+
use24hFormat: true,
115+
onDateTimeChanged: (DateTime newDate) {
116+
setState(() => dateTime = newDate);
117+
},
118+
),
119+
))
77120
],
78121
),
79-
Padding(
80-
padding: const EdgeInsets.only(top: 16.0),
81-
child: Row(
82-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
83-
children: [
84-
ElevatedButton(
85-
key: cupertinoDateButtonKey,
86-
style: ElevatedButton.styleFrom(backgroundColor: Colors.purple.shade300),
87-
onPressed: () => _showDialog(
88-
CupertinoDatePicker(
89-
initialDateTime: dateTime,
90-
mode: CupertinoDatePickerMode.date,
91-
use24hFormat: true,
92-
// This shows day of week alongside day of month
93-
showDayOfWeek: true,
94-
// This is called when the user changes the date.
95-
onDateTimeChanged: (DateTime newDate) {
96-
setState(() => dateTime = newDate);
97-
},
98-
),
122+
),
123+
Padding(
124+
padding: const EdgeInsets.only(top: 16.0),
125+
child: Row(
126+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
127+
children: [
128+
ElevatedButton(
129+
key: cupertinoDateTimeButtonKey,
130+
style: ElevatedButton.styleFrom(backgroundColor: Colors.green.shade400),
131+
onPressed: () => _showDialog(
132+
CupertinoDatePicker(
133+
initialDateTime: dateTime,
134+
mode: CupertinoDatePickerMode.dateAndTime,
135+
use24hFormat: true,
136+
onDateTimeChanged: (DateTime newDate) {
137+
setState(() => dateTime = newDate);
138+
},
99139
),
100-
child: const Text(
101-
"Date",
102-
style: TextStyle(fontSize: 20),
103-
)),
104-
ElevatedButton(
105-
key: cupertinoTimeButtonKey,
106-
style: ElevatedButton.styleFrom(backgroundColor: Colors.purple.shade300),
107-
child: const Text(
108-
"Time",
109-
style: TextStyle(fontSize: 20),
110-
),
111-
onPressed: () => _showDialog(
112-
CupertinoDatePicker(
113-
initialDateTime: dateTime,
114-
mode: CupertinoDatePickerMode.time,
115-
use24hFormat: true,
116-
onDateTimeChanged: (DateTime newDate) {
117-
setState(() => dateTime = newDate);
118-
},
119-
),
120-
))
121-
],
122-
),
140+
),
141+
child: const Text(
142+
"DateTime",
143+
style: TextStyle(fontSize: 20),
144+
)),
145+
],
123146
),
124-
Padding(
125-
padding: const EdgeInsets.only(top: 16.0),
126-
child: Row(
127-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
128-
children: [
129-
ElevatedButton(
130-
key: cupertinoDateTimeButtonKey,
131-
style: ElevatedButton.styleFrom(backgroundColor: Colors.green.shade400),
132-
onPressed: () => _showDialog(
133-
CupertinoDatePicker(
134-
initialDateTime: dateTime,
135-
mode: CupertinoDatePickerMode.dateAndTime,
136-
use24hFormat: true,
137-
onDateTimeChanged: (DateTime newDate) {
138-
setState(() => dateTime = newDate);
139-
},
140-
),
141-
),
142-
child: const Text(
143-
"DateTime",
144-
style: TextStyle(fontSize: 20),
145-
)),
146-
],
147-
),
148-
)
149-
],
150-
),
147+
)
148+
],
151149
),
152150
);
153151
}

lib/material.dart

+82-84
Original file line numberDiff line numberDiff line change
@@ -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
}

test/widget_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import 'package:app/cupertino.dart';
99
import 'package:app/material.dart';
10-
import 'package:flutter/material.dart';
1110
import 'package:flutter_test/flutter_test.dart';
1211

1312
import 'package:app/main.dart';

0 commit comments

Comments
 (0)