Skip to content

Commit a3d622c

Browse files
authored
Merge branch 'master' into safearea
2 parents 145dfb1 + df4ed6f commit a3d622c

File tree

13 files changed

+306
-227
lines changed

13 files changed

+306
-227
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ International:
5757
## Usage
5858

5959
```
60-
FlatButton(
60+
TextButton(
6161
onPressed: () {
6262
DatePicker.showDatePicker(context,
6363
showTitleActions: true,

example/android/app/src/main/AndroidManifest.xml

+15-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
additional functionality it is fine to subclass or reimplement
1414
FlutterApplication and put your custom class here. -->
1515
<application
16-
android:name="io.flutter.app.FlutterApplication"
1716
android:label="example"
1817
android:icon="@mipmap/ic_launcher">
1918
<activity
@@ -23,17 +22,26 @@
2322
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
2423
android:hardwareAccelerated="true"
2524
android:windowSoftInputMode="adjustResize">
26-
<!-- This keeps the window background of the activity showing
27-
until Flutter renders its first frame. It can be removed if
28-
there is no splash screen (such as the default splash screen
29-
defined in @style/LaunchTheme). -->
25+
<!-- Specify that the launch screen should continue being displayed -->
26+
<!-- until Flutter renders its first frame. -->
3027
<meta-data
31-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
32-
android:value="true" />
28+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
29+
android:resource="@drawable/launch_background" />
30+
31+
<!-- Theme to apply as soon as Flutter begins rendering frames -->
32+
<meta-data
33+
android:name="io.flutter.embedding.android.NormalTheme"
34+
android:resource="@style/NormalTheme" />
35+
3336
<intent-filter>
3437
<action android:name="android.intent.action.MAIN"/>
3538
<category android:name="android.intent.category.LAUNCHER"/>
3639
</intent-filter>
3740
</activity>
41+
42+
<meta-data
43+
android:name="flutterEmbedding"
44+
android:value="2" />
45+
3846
</application>
3947
</manifest>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
package com.realank.example;
2+
import io.flutter.embedding.android.FlutterActivity;
23

3-
import android.os.Bundle;
4-
import io.flutter.app.FlutterActivity;
5-
import io.flutter.plugins.GeneratedPluginRegistrant;
6-
7-
public class MainActivity extends FlutterActivity {
8-
@Override
9-
protected void onCreate(Bundle savedInstanceState) {
10-
super.onCreate(savedInstanceState);
11-
GeneratedPluginRegistrant.registerWith(this);
12-
}
13-
}
4+
public class MainActivity extends FlutterActivity {}

example/android/app/src/main/res/values/styles.xml

+4
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
Flutter draws its first frame -->
66
<item name="android:windowBackground">@drawable/launch_background</item>
77
</style>
8+
<!-- You can name this style whatever you'd like -->
9+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
10+
<item name="android:windowBackground">@drawable/launch_background</item>
11+
</style>
812
</resources>

example/ios/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Icon?
4040
/Flutter/Flutter.framework
4141
/Flutter/Generated.xcconfig
4242
/ServiceDefinitions.json
43+
/Flutter/flutter_export_environment.sh
4344

4445
Pods/
4546
.symlinks/

example/lib/main.dart

+77-39
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ class CustomPicker extends CommonPickerModel {
88
return '$value'.padLeft(length, "0");
99
}
1010

11-
CustomPicker({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
11+
CustomPicker({DateTime? currentTime, LocaleType? locale})
12+
: super(locale: locale) {
1213
this.currentTime = currentTime ?? DateTime.now();
1314
this.setLeftIndex(this.currentTime.hour);
1415
this.setMiddleIndex(this.currentTime.minute);
1516
this.setRightIndex(this.currentTime.second);
1617
}
1718

1819
@override
19-
String leftStringAtIndex(int index) {
20+
String? leftStringAtIndex(int index) {
2021
if (index >= 0 && index < 24) {
2122
return this.digits(index, 2);
2223
} else {
@@ -25,7 +26,7 @@ class CustomPicker extends CommonPickerModel {
2526
}
2627

2728
@override
28-
String middleStringAtIndex(int index) {
29+
String? middleStringAtIndex(int index) {
2930
if (index >= 0 && index < 60) {
3031
return this.digits(index, 2);
3132
} else {
@@ -34,7 +35,7 @@ class CustomPicker extends CommonPickerModel {
3435
}
3536

3637
@override
37-
String rightStringAtIndex(int index) {
38+
String? rightStringAtIndex(int index) {
3839
if (index >= 0 && index < 60) {
3940
return this.digits(index, 2);
4041
} else {
@@ -60,10 +61,20 @@ class CustomPicker extends CommonPickerModel {
6061
@override
6162
DateTime finalTime() {
6263
return currentTime.isUtc
63-
? DateTime.utc(currentTime.year, currentTime.month, currentTime.day,
64-
this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex())
65-
: DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(),
66-
this.currentMiddleIndex(), this.currentRightIndex());
64+
? DateTime.utc(
65+
currentTime.year,
66+
currentTime.month,
67+
currentTime.day,
68+
this.currentLeftIndex(),
69+
this.currentMiddleIndex(),
70+
this.currentRightIndex())
71+
: DateTime(
72+
currentTime.year,
73+
currentTime.month,
74+
currentTime.day,
75+
this.currentLeftIndex(),
76+
this.currentMiddleIndex(),
77+
this.currentRightIndex());
6778
}
6879
}
6980

@@ -91,7 +102,7 @@ class HomePage extends StatelessWidget {
91102
body: Center(
92103
child: Column(
93104
children: <Widget>[
94-
FlatButton(
105+
TextButton(
95106
onPressed: () {
96107
DatePicker.showDatePicker(context,
97108
showTitleActions: true,
@@ -101,10 +112,14 @@ class HomePage extends StatelessWidget {
101112
headerColor: Colors.orange,
102113
backgroundColor: Colors.blue,
103114
itemStyle: TextStyle(
104-
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18),
105-
doneStyle: TextStyle(color: Colors.white, fontSize: 16)),
115+
color: Colors.white,
116+
fontWeight: FontWeight.bold,
117+
fontSize: 18),
118+
doneStyle:
119+
TextStyle(color: Colors.white, fontSize: 16)),
106120
onChanged: (date) {
107-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
121+
print('change $date in time zone ' +
122+
date.timeZoneOffset.inHours.toString());
108123
}, onConfirm: (date) {
109124
print('confirm $date');
110125
}, currentTime: DateTime.now(), locale: LocaleType.en);
@@ -113,10 +128,12 @@ class HomePage extends StatelessWidget {
113128
'show date picker(custom theme &date time range)',
114129
style: TextStyle(color: Colors.blue),
115130
)),
116-
FlatButton(
131+
TextButton(
117132
onPressed: () {
118-
DatePicker.showTimePicker(context, showTitleActions: true, onChanged: (date) {
119-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
133+
DatePicker.showTimePicker(context, showTitleActions: true,
134+
onChanged: (date) {
135+
print('change $date in time zone ' +
136+
date.timeZoneOffset.inHours.toString());
120137
}, onConfirm: (date) {
121138
print('confirm $date');
122139
}, currentTime: DateTime.now());
@@ -125,10 +142,12 @@ class HomePage extends StatelessWidget {
125142
'show time picker',
126143
style: TextStyle(color: Colors.blue),
127144
)),
128-
FlatButton(
145+
TextButton(
129146
onPressed: () {
130-
DatePicker.showTime12hPicker(context, showTitleActions: true, onChanged: (date) {
131-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
147+
DatePicker.showTime12hPicker(context, showTitleActions: true,
148+
onChanged: (date) {
149+
print('change $date in time zone ' +
150+
date.timeZoneOffset.inHours.toString());
132151
}, onConfirm: (date) {
133152
print('confirm $date');
134153
}, currentTime: DateTime.now());
@@ -137,13 +156,14 @@ class HomePage extends StatelessWidget {
137156
'show 12H time picker with AM/PM',
138157
style: TextStyle(color: Colors.blue),
139158
)),
140-
FlatButton(
159+
TextButton(
141160
onPressed: () {
142161
DatePicker.showDateTimePicker(context,
143162
showTitleActions: true,
144163
minTime: DateTime(2020, 5, 5, 20, 50),
145164
maxTime: DateTime(2020, 6, 7, 05, 09), onChanged: (date) {
146-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
165+
print('change $date in time zone ' +
166+
date.timeZoneOffset.inHours.toString());
147167
}, onConfirm: (date) {
148168
print('confirm $date');
149169
}, locale: LocaleType.zh);
@@ -152,10 +172,12 @@ class HomePage extends StatelessWidget {
152172
'show date time picker (Chinese)',
153173
style: TextStyle(color: Colors.blue),
154174
)),
155-
FlatButton(
175+
TextButton(
156176
onPressed: () {
157-
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
158-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
177+
DatePicker.showDateTimePicker(context, showTitleActions: true,
178+
onChanged: (date) {
179+
print('change $date in time zone ' +
180+
date.timeZoneOffset.inHours.toString());
159181
}, onConfirm: (date) {
160182
print('confirm $date');
161183
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
@@ -164,49 +186,65 @@ class HomePage extends StatelessWidget {
164186
'show date time picker (English-America)',
165187
style: TextStyle(color: Colors.blue),
166188
)),
167-
FlatButton(
189+
TextButton(
168190
onPressed: () {
169-
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
170-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
191+
DatePicker.showDateTimePicker(context, showTitleActions: true,
192+
onChanged: (date) {
193+
print('change $date in time zone ' +
194+
date.timeZoneOffset.inHours.toString());
171195
}, onConfirm: (date) {
172196
print('confirm $date');
173-
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.nl);
197+
},
198+
currentTime: DateTime(2008, 12, 31, 23, 12, 34),
199+
locale: LocaleType.nl);
174200
},
175201
child: Text(
176202
'show date time picker (Dutch)',
177203
style: TextStyle(color: Colors.blue),
178204
)),
179-
FlatButton(
205+
TextButton(
180206
onPressed: () {
181-
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
182-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
207+
DatePicker.showDateTimePicker(context, showTitleActions: true,
208+
onChanged: (date) {
209+
print('change $date in time zone ' +
210+
date.timeZoneOffset.inHours.toString());
183211
}, onConfirm: (date) {
184212
print('confirm $date');
185-
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.ru);
213+
},
214+
currentTime: DateTime(2008, 12, 31, 23, 12, 34),
215+
locale: LocaleType.ru);
186216
},
187217
child: Text(
188218
'show date time picker (Russian)',
189219
style: TextStyle(color: Colors.blue),
190220
)),
191-
FlatButton(
221+
TextButton(
192222
onPressed: () {
193-
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
194-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
223+
DatePicker.showDateTimePicker(context, showTitleActions: true,
224+
onChanged: (date) {
225+
print('change $date in time zone ' +
226+
date.timeZoneOffset.inHours.toString());
195227
}, onConfirm: (date) {
196228
print('confirm $date');
197-
}, currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34), locale: LocaleType.de);
229+
},
230+
currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34),
231+
locale: LocaleType.de);
198232
},
199233
child: Text(
200234
'show date time picker in UTC (German)',
201235
style: TextStyle(color: Colors.blue),
202236
)),
203-
FlatButton(
237+
TextButton(
204238
onPressed: () {
205-
DatePicker.showPicker(context, showTitleActions: true, onChanged: (date) {
206-
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
239+
DatePicker.showPicker(context, showTitleActions: true,
240+
onChanged: (date) {
241+
print('change $date in time zone ' +
242+
date.timeZoneOffset.inHours.toString());
207243
}, onConfirm: (date) {
208244
print('confirm $date');
209-
}, pickerModel: CustomPicker(currentTime: DateTime.now()), locale: LocaleType.en);
245+
},
246+
pickerModel: CustomPicker(currentTime: DateTime.now()),
247+
locale: LocaleType.en);
210248
},
211249
child: Text(
212250
'show custom time picker,\nyou can custom picker model like this',

example/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ description: A new Flutter application.
1010
version: 1.0.0+1
1111

1212
environment:
13-
sdk: ">=2.0.0-dev.68.0 <3.0.0"
13+
sdk: ">=2.12.0 <3.0.0"
1414

1515
dependencies:
1616
flutter:
1717
sdk: flutter
1818

1919
# The following adds the Cupertino Icons font to your application.
2020
# Use with the CupertinoIcons class for iOS style icons.
21-
cupertino_icons: ^0.1.2
21+
cupertino_icons: ^1.0.2
2222
flutter_datetime_picker:
2323
path: ../
2424

0 commit comments

Comments
 (0)