Skip to content

migrating to null safety #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/liuyanbo/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example"
export "FLUTTER_TARGET=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example/lib/main.dart"
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Projetos\flutter_datetime_picker\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/Users/liuyanbo/flutter/bin/cache/artifacts/engine/ios"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
42 changes: 21 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class CustomPicker extends CommonPickerModel {
return '$value'.padLeft(length, "0");
}

CustomPicker({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
CustomPicker({DateTime? currentTime, LocaleType? locale}) : super(locale: locale) {
this.currentTime = currentTime ?? DateTime.now();
this.setLeftIndex(this.currentTime.hour);
this.setMiddleIndex(this.currentTime.minute);
this.setRightIndex(this.currentTime.second);
this.setLeftIndex(this.currentTime!.hour);
this.setMiddleIndex(this.currentTime!.minute);
this.setRightIndex(this.currentTime!.second);
}

@override
String leftStringAtIndex(int index) {
String? leftStringAtIndex(int index) {
if (index >= 0 && index < 24) {
return this.digits(index, 2);
} else {
Expand All @@ -25,7 +25,7 @@ class CustomPicker extends CommonPickerModel {
}

@override
String middleStringAtIndex(int index) {
String? middleStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return this.digits(index, 2);
} else {
Expand All @@ -34,7 +34,7 @@ class CustomPicker extends CommonPickerModel {
}

@override
String rightStringAtIndex(int index) {
String? rightStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return this.digits(index, 2);
} else {
Expand All @@ -59,11 +59,11 @@ class CustomPicker extends CommonPickerModel {

@override
DateTime finalTime() {
return currentTime.isUtc
? DateTime.utc(currentTime.year, currentTime.month, currentTime.day,
this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex())
: DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(),
this.currentMiddleIndex(), this.currentRightIndex());
return currentTime!.isUtc
? DateTime.utc(currentTime!.year, currentTime!.month, currentTime!.day,
this.currentLeftIndex()!, this.currentMiddleIndex()!, this.currentRightIndex()!)
: DateTime(currentTime!.year, currentTime!.month, currentTime!.day, this.currentLeftIndex()!,
this.currentMiddleIndex()!, this.currentRightIndex()!);
}
}

Expand Down Expand Up @@ -104,7 +104,7 @@ class HomePage extends StatelessWidget {
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18),
doneStyle: TextStyle(color: Colors.white, fontSize: 16)),
onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now(), locale: LocaleType.en);
Expand All @@ -116,7 +116,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now());
Expand All @@ -128,7 +128,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showTime12hPicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now());
Expand All @@ -143,7 +143,7 @@ class HomePage extends StatelessWidget {
showTitleActions: true,
minTime: DateTime(2020, 5, 5, 20, 50),
maxTime: DateTime(2020, 6, 7, 05, 09), onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, locale: LocaleType.zh);
Expand All @@ -155,7 +155,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
Expand All @@ -167,7 +167,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.nl);
Expand All @@ -179,7 +179,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.ru);
Expand All @@ -191,7 +191,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34), locale: LocaleType.de);
Expand All @@ -203,7 +203,7 @@ class HomePage extends StatelessWidget {
FlatButton(
onPressed: () {
DatePicker.showPicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
print('change $date in time zone ' + date!.timeZoneOffset.inHours.toString());
}, onConfirm: (date) {
print('confirm $date');
}, pickerModel: CustomPicker(currentTime: DateTime.now()), locale: LocaleType.en);
Expand Down
4 changes: 1 addition & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: A new Flutter application.
version: 1.0.0+1

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -26,13 +26,11 @@ dev_dependencies:
flutter_test:
sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down
Loading