diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 00000000..f47b422c
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,228 @@
+# Specify analysis options.
+#
+# Until there are meta linter rules, each desired lint must be explicitly enabled.
+# See: https://github.com/dart-lang/linter/issues/288
+#
+# For a list of lints, see: http://dart-lang.github.io/linter/lints/
+# See the configuration guide for more
+# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
+#
+# There are other similar analysis options files in the flutter repos,
+# which should be kept in sync with this file:
+#
+# - analysis_options.yaml (this file)
+# - packages/flutter/lib/analysis_options_user.yaml
+# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
+# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
+#
+# This file contains the analysis options used by Flutter tools, such as IntelliJ,
+# Android Studio, and the `flutter analyze` command.
+
+analyzer:
+ strong-mode:
+ implicit-casts: false
+ errors:
+ # treat missing required parameters as a warning (not a hint)
+ missing_required_param: warning
+ # treat missing returns as a warning (not a hint)
+ missing_return: warning
+ # allow having TODOs in the code
+ todo: ignore
+ # allow self-reference to deprecated members (we do this because otherwise we have
+ # to annotate every member in every test, assert, etc, when we deprecate something)
+ deprecated_member_use_from_same_package: ignore
+ # Ignore analyzer hints for updating pubspecs when using Future or
+ # Stream and not importing dart:async
+ # Please see https://github.com/flutter/flutter/pull/24528 for details.
+ sdk_version_async_exported_from_core: ignore
+ # Turned off until null-safe rollout is complete.
+ unnecessary_null_comparison: ignore
+ exclude:
+ - "bin/cache/**"
+ enable-experiment:
+ - non-nullable
+
+linter:
+ rules:
+ # these rules are documented on and in the same order as
+ # the Dart Lint rules page to make maintenance easier
+ # https://github.com/dart-lang/linter/blob/master/example/all.yaml
+ - always_declare_return_types
+ - always_put_control_body_on_new_line
+ # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
+ - always_require_non_null_named_parameters
+ - always_specify_types
+ # - always_use_package_imports # we do this commonly
+ - annotate_overrides
+ # - avoid_annotating_with_dynamic # conflicts with always_specify_types
+ - avoid_bool_literals_in_conditional_expressions
+ # - avoid_catches_without_on_clauses # we do this commonly
+ # - avoid_catching_errors # we do this commonly
+ - avoid_classes_with_only_static_members
+ # - avoid_double_and_int_checks # only useful when targeting JS runtime
+ # - avoid_dynamic_calls # not yet tested
+ - avoid_empty_else
+ - avoid_equals_and_hash_code_on_mutable_classes
+ # - avoid_escaping_inner_quotes # not yet tested
+ - avoid_field_initializers_in_const_classes
+ - avoid_function_literals_in_foreach_calls
+ # - avoid_implementing_value_types # not yet tested
+ - avoid_init_to_null
+ # - avoid_js_rounded_ints # only useful when targeting JS runtime
+ - avoid_null_checks_in_equality_operators
+ # - avoid_positional_boolean_parameters # not yet tested
+ # - avoid_print # not yet tested
+ # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
+ # - avoid_redundant_argument_values # not yet tested
+ - avoid_relative_lib_imports
+ - avoid_renaming_method_parameters
+ - avoid_return_types_on_setters
+ # - avoid_returning_null # there are plenty of valid reasons to return null
+ # - avoid_returning_null_for_future # not yet tested
+ - avoid_returning_null_for_void
+ # - avoid_returning_this # there are plenty of valid reasons to return this
+ # - avoid_setters_without_getters # not yet tested
+ - avoid_shadowing_type_parameters
+ - avoid_single_cascade_in_expression_statements
+ - avoid_slow_async_io
+ - avoid_type_to_string
+ - avoid_types_as_parameter_names
+ # - avoid_types_on_closure_parameters # conflicts with always_specify_types
+ - avoid_unnecessary_containers
+ - avoid_unused_constructor_parameters
+ - avoid_void_async
+ # - avoid_web_libraries_in_flutter # not yet tested
+ - await_only_futures
+ - camel_case_extensions
+ - camel_case_types
+ - cancel_subscriptions
+ # - cascade_invocations # not yet tested
+ - cast_nullable_to_non_nullable
+ # - close_sinks # not reliable enough
+ # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
+ # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
+ - control_flow_in_finally
+ # - diagnostic_describe_all_properties # not yet tested
+ - directives_ordering
+ # - do_not_use_environment # we do this commonly
+ - empty_catches
+ - empty_constructor_bodies
+ - empty_statements
+ - exhaustive_cases
+ - file_names
+ - flutter_style_todos
+ - hash_and_equals
+ - implementation_imports
+ # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
+ - iterable_contains_unrelated_type
+ # - join_return_with_assignment # not required by flutter style
+ - leading_newlines_in_multiline_strings
+ - library_names
+ - library_prefixes
+ # - lines_longer_than_80_chars # not required by flutter style
+ - list_remove_unrelated_type
+ # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
+ - missing_whitespace_between_adjacent_strings
+ - no_adjacent_strings_in_list
+ # - no_default_cases # too many false positives
+ - no_duplicate_case_values
+ - no_logic_in_create_state
+ # - no_runtimeType_toString # ok in tests; we enable this only in packages/
+ - non_constant_identifier_names
+ - null_check_on_nullable_type_parameter
+ - null_closures
+ # - omit_local_variable_types # opposite of always_specify_types
+ # - one_member_abstracts # too many false positives
+ # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
+ - overridden_fields
+ - package_api_docs
+ - package_names
+ - package_prefixed_library_names
+ # - parameter_assignments # we do this commonly
+ - prefer_adjacent_string_concatenation
+ - prefer_asserts_in_initializer_lists
+ # - prefer_asserts_with_message # not required by flutter style
+ - prefer_collection_literals
+ - prefer_conditional_assignment
+ - prefer_const_constructors
+ - prefer_const_constructors_in_immutables
+ - prefer_const_declarations
+ - prefer_const_literals_to_create_immutables
+ # - prefer_constructors_over_static_methods # far too many false positives
+ - prefer_contains
+ # - prefer_double_quotes # opposite of prefer_single_quotes
+ - prefer_equal_for_default_values
+ # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
+ - prefer_final_fields
+ - prefer_final_in_for_each
+ - prefer_final_locals
+ - prefer_for_elements_to_map_fromIterable
+ - prefer_foreach
+ - prefer_function_declarations_over_variables
+ - prefer_generic_function_type_aliases
+ - prefer_if_elements_to_conditional_expressions
+ - prefer_if_null_operators
+ - prefer_initializing_formals
+ - prefer_inlined_adds
+ # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
+ # - prefer_interpolation_to_compose_strings # doesn't work with raw strings, see https://github.com/dart-lang/linter/issues/2490
+ - prefer_is_empty
+ - prefer_is_not_empty
+ - prefer_is_not_operator
+ - prefer_iterable_whereType
+ # - prefer_mixin # https://github.com/dart-lang/language/issues/32
+ - prefer_null_aware_operators
+ # - prefer_relative_imports # incompatible with sub-package imports
+ - prefer_single_quotes
+ - prefer_spread_collections
+ - prefer_typing_uninitialized_variables
+ - prefer_void_to_null
+ - provide_deprecation_message
+ # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
+ - recursive_getters
+ - sized_box_for_whitespace
+ - slash_for_doc_comments
+ # - sort_child_properties_last # not yet tested
+ - sort_constructors_first
+ # - sort_pub_dependencies # prevents separating pinned transitive dependencies
+ - sort_unnamed_constructors_first
+ - test_types_in_equals
+ - throw_in_finally
+ - tighten_type_of_initializing_formals
+ # - type_annotate_public_apis # subset of always_specify_types
+ - type_init_formals
+ # - unawaited_futures # too many false positives
+ - unnecessary_await_in_return
+ - unnecessary_brace_in_string_interps
+ - unnecessary_const
+ # - unnecessary_final # conflicts with prefer_final_locals
+ - unnecessary_getters_setters
+ # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
+ - unnecessary_new
+ - unnecessary_null_aware_assignments
+ # - unnecessary_null_checks # not yet tested
+ - unnecessary_null_in_if_null_operators
+ - unnecessary_nullable_for_final_variable_declarations
+ - unnecessary_overrides
+ - unnecessary_parenthesis
+ # - unnecessary_raw_strings # not yet tested
+ - unnecessary_statements
+ - unnecessary_string_escapes
+ - unnecessary_string_interpolations
+ - unnecessary_this
+ - unrelated_type_equality_checks
+ # - unsafe_html # not yet tested
+ - use_full_hex_values_for_flutter_colors
+ - use_function_type_syntax_for_parameters
+ # - use_if_null_to_convert_nulls_to_bools # not yet tested
+ - use_is_even_rather_than_modulo
+ - use_key_in_widget_constructors
+ - use_late_for_private_fields_and_variables
+ # - use_named_constants # not yet tested
+ - use_raw_strings
+ - use_rethrow_when_possible
+ # - use_setters_to_change_properties # not yet tested
+ # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
+ # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
+ - valid_regexps
+ - void_checks
\ No newline at end of file
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index eb3d7156..bbde1d3b 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -30,6 +30,9 @@
+
diff --git a/example/android/app/src/main/java/com/realank/example/MainActivity.java b/example/android/app/src/main/java/com/realank/example/MainActivity.java
index f0a7e5df..33949e49 100644
--- a/example/android/app/src/main/java/com/realank/example/MainActivity.java
+++ b/example/android/app/src/main/java/com/realank/example/MainActivity.java
@@ -1,13 +1,15 @@
package com.realank.example;
import android.os.Bundle;
-import io.flutter.app.FlutterActivity;
+
+import io.flutter.embedding.android.FlutterActivity;
+import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- GeneratedPluginRegistrant.registerWith(this);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ GeneratedPluginRegistrant.registerWith(new FlutterEngine(this));
+ }
}
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 9e4e79be..fab3c2e1 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.2'
+ classpath 'com.android.tools.build:gradle:4.1.3'
}
}
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 79ea3e75..2a723c88 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Thu Nov 21 17:00:56 IST 2019
+#Thu Apr 01 12:53:12 HKT 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh
index 2f93d56b..da318df9 100755
--- a/example/ios/Flutter/flutter_export_environment.sh
+++ b/example/ios/Flutter/flutter_export_environment.sh
@@ -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=/Users/felixmo/flutter"
+export "FLUTTER_APPLICATION_PATH=/Users/felixmo/Desktop/trustME/sample/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 "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"
diff --git a/example/lib/main.dart b/example/lib/main.dart
index c5c12362..8ce4c582 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,42 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
-void main() => runApp(new MyApp());
+void main() => runApp(MyApp());
class CustomPicker extends CommonPickerModel {
String digits(int value, int length) {
- return '$value'.padLeft(length, "0");
+ 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);
+ setLeftIndex(this.currentTime!.hour);
+ setMiddleIndex(this.currentTime!.minute);
+ setRightIndex(this.currentTime!.second);
}
@override
- String leftStringAtIndex(int index) {
+ String? leftStringAtIndex(int index) {
if (index >= 0 && index < 24) {
- return this.digits(index, 2);
+ return digits(index, 2);
} else {
return null;
}
}
@override
- String middleStringAtIndex(int index) {
+ String? middleStringAtIndex(int index) {
if (index >= 0 && index < 60) {
- return this.digits(index, 2);
+ return digits(index, 2);
} else {
return null;
}
}
@override
- String rightStringAtIndex(int index) {
+ String? rightStringAtIndex(int index) {
if (index >= 0 && index < 60) {
- return this.digits(index, 2);
+ return digits(index, 2);
} else {
return null;
}
@@ -44,12 +44,12 @@ class CustomPicker extends CommonPickerModel {
@override
String leftDivider() {
- return "|";
+ return '|';
}
@override
String rightDivider() {
- return "|";
+ return '|';
}
@override
@@ -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, currentLeftIndex()!,
+ currentMiddleIndex()!, currentRightIndex()!)
+ : DateTime(currentTime!.year, currentTime!.month, currentTime!.day, currentLeftIndex()!, currentMiddleIndex()!,
+ currentRightIndex()!);
}
}
@@ -71,12 +71,12 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
- return new MaterialApp(
+ return MaterialApp(
title: 'Flutter Demo',
- theme: new ThemeData(
+ theme: ThemeData(
primarySwatch: Colors.blue,
),
- home: new HomePage(),
+ home: HomePage(),
);
}
}
@@ -86,7 +86,7 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text('Datetime Picker'),
+ title: const Text('Datetime Picker'),
),
body: Center(
child: Column(
@@ -97,19 +97,17 @@ class HomePage extends StatelessWidget {
showTitleActions: true,
minTime: DateTime(2018, 3, 5),
maxTime: DateTime(2019, 6, 7),
- theme: DatePickerTheme(
+ theme: const DatePickerTheme(
headerColor: Colors.orange,
backgroundColor: Colors.blue,
- itemStyle: TextStyle(
- color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18),
- doneStyle: TextStyle(color: Colors.white, fontSize: 16)),
- onChanged: (date) {
+ itemStyle: TextStyle(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());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime.now(), locale: LocaleType.en);
},
- child: Text(
+ child: const Text(
'show date picker(custom theme &date time range)',
style: TextStyle(color: Colors.blue),
)),
@@ -117,11 +115,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime.now());
},
- child: Text(
+ child: const Text(
'show time picker',
style: TextStyle(color: Colors.blue),
)),
@@ -129,11 +127,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showTime12hPicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime.now());
},
- child: Text(
+ child: const Text(
'show 12H time picker with AM/PM',
style: TextStyle(color: Colors.blue),
)),
@@ -144,11 +142,11 @@ class HomePage extends StatelessWidget {
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());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, locale: LocaleType.zh);
},
- child: Text(
+ child: const Text(
'show date time picker (Chinese)',
style: TextStyle(color: Colors.blue),
)),
@@ -156,11 +154,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
},
- child: Text(
+ child: const Text(
'show date time picker (English-America)',
style: TextStyle(color: Colors.blue),
)),
@@ -168,11 +166,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.nl);
},
- child: Text(
+ child: const Text(
'show date time picker (Dutch)',
style: TextStyle(color: Colors.blue),
)),
@@ -180,11 +178,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime(2008, 12, 31, 23, 12, 34), locale: LocaleType.ru);
},
- child: Text(
+ child: const Text(
'show date time picker (Russian)',
style: TextStyle(color: Colors.blue),
)),
@@ -192,11 +190,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showDateTimePicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, currentTime: DateTime.utc(2019, 12, 31, 23, 12, 34), locale: LocaleType.de);
},
- child: Text(
+ child: const Text(
'show date time picker in UTC (German)',
style: TextStyle(color: Colors.blue),
)),
@@ -204,11 +202,11 @@ class HomePage extends StatelessWidget {
onPressed: () {
DatePicker.showPicker(context, showTitleActions: true, onChanged: (date) {
print('change $date in time zone ' + date.timeZoneOffset.inHours.toString());
- }, onConfirm: (date) {
+ }, onConfirm: (DateTime date) {
print('confirm $date');
}, pickerModel: CustomPicker(currentTime: DateTime.now()), locale: LocaleType.en);
},
- child: Text(
+ child: const Text(
'show custom time picker,\nyou can custom picker model like this',
style: TextStyle(color: Colors.blue),
)),
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 6914dd16..dd8f150c 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -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:
diff --git a/lib/flutter_datetime_picker.dart b/lib/flutter_datetime_picker.dart
index 572c47dd..b9dd365c 100644
--- a/lib/flutter_datetime_picker.dart
+++ b/lib/flutter_datetime_picker.dart
@@ -11,37 +11,36 @@ export 'package:flutter_datetime_picker/src/datetime_picker_theme.dart';
export 'package:flutter_datetime_picker/src/date_model.dart';
export 'package:flutter_datetime_picker/src/i18n_model.dart';
-typedef DateChangedCallback(DateTime time);
-typedef DateCancelledCallback();
-typedef String StringAtIndexCallBack(int index);
+typedef DateChangedCallback = Function(DateTime time);
+typedef DateCancelledCallback = Function();
+typedef StringAtIndexCallBack = String? Function(int index);
class DatePicker {
///
/// Display date picker bottom sheet.
///
- static Future showDatePicker(
+ static Future showDatePicker(
BuildContext context, {
- bool showTitleActions: true,
- DateTime minTime,
- DateTime maxTime,
- DateChangedCallback onChanged,
- DateChangedCallback onConfirm,
- DateCancelledCallback onCancel,
- locale: LocaleType.en,
- DateTime currentTime,
- DatePickerTheme theme,
+ bool showTitleActions = true,
+ DateTime? minTime,
+ DateTime? maxTime,
+ DateChangedCallback? onChanged,
+ DateChangedCallback? onConfirm,
+ DateCancelledCallback? onCancel,
+ LocaleType locale = LocaleType.en,
+ DateTime? currentTime,
+ DatePickerTheme? theme,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
showTitleActions: showTitleActions,
- onChanged: onChanged,
- onConfirm: onConfirm,
- onCancel: onCancel,
+ onChanged: onChanged!,
+ onConfirm: onConfirm!,
+ onCancel: onCancel!,
locale: locale,
theme: theme,
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
pickerModel: DatePickerModel(
currentTime: currentTime,
maxTime: maxTime,
@@ -55,28 +54,27 @@ class DatePicker {
///
/// Display time picker bottom sheet.
///
- static Future showTimePicker(
+ static Future showTimePicker(
BuildContext context, {
- bool showTitleActions: true,
- bool showSecondsColumn: true,
- DateChangedCallback onChanged,
- DateChangedCallback onConfirm,
- DateCancelledCallback onCancel,
- locale: LocaleType.en,
- DateTime currentTime,
- DatePickerTheme theme,
+ bool showTitleActions = true,
+ bool showSecondsColumn = true,
+ DateChangedCallback? onChanged,
+ DateChangedCallback? onConfirm,
+ DateCancelledCallback? onCancel,
+ LocaleType locale = LocaleType.en,
+ DateTime? currentTime,
+ DatePickerTheme? theme,
}) async {
return await Navigator.push(
context,
_DatePickerRoute(
showTitleActions: showTitleActions,
- onChanged: onChanged,
- onConfirm: onConfirm,
- onCancel: onCancel,
+ onChanged: onChanged!,
+ onConfirm: onConfirm!,
+ onCancel: onCancel!,
locale: locale,
theme: theme,
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
pickerModel: TimePickerModel(
currentTime: currentTime,
locale: locale,
@@ -89,15 +87,15 @@ class DatePicker {
///
/// Display time picker bottom sheet with AM/PM.
///
- static Future showTime12hPicker(
+ static Future showTime12hPicker(
BuildContext context, {
- bool showTitleActions: true,
- DateChangedCallback onChanged,
- DateChangedCallback onConfirm,
- DateCancelledCallback onCancel,
- locale: LocaleType.en,
- DateTime currentTime,
- DatePickerTheme theme,
+ bool showTitleActions = true,
+ DateChangedCallback? onChanged,
+ DateChangedCallback? onConfirm,
+ DateCancelledCallback? onCancel,
+ LocaleType locale = LocaleType.en,
+ DateTime? currentTime,
+ DatePickerTheme? theme,
}) async {
return await Navigator.push(
context,
@@ -108,8 +106,7 @@ class DatePicker {
onCancel: onCancel,
locale: locale,
theme: theme,
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
pickerModel: Time12hPickerModel(
currentTime: currentTime,
locale: locale,
@@ -121,17 +118,17 @@ class DatePicker {
///
/// Display date&time picker bottom sheet.
///
- static Future showDateTimePicker(
+ static Future showDateTimePicker(
BuildContext context, {
bool showTitleActions: true,
- DateTime minTime,
- DateTime maxTime,
- DateChangedCallback onChanged,
- DateChangedCallback onConfirm,
- DateCancelledCallback onCancel,
- locale: LocaleType.en,
- DateTime currentTime,
- DatePickerTheme theme,
+ DateTime? minTime,
+ DateTime? maxTime,
+ DateChangedCallback? onChanged,
+ DateChangedCallback? onConfirm,
+ DateCancelledCallback? onCancel,
+ LocaleType locale = LocaleType.en,
+ DateTime? currentTime,
+ DatePickerTheme? theme,
}) async {
return await Navigator.push(
context,
@@ -142,8 +139,7 @@ class DatePicker {
onCancel: onCancel,
locale: locale,
theme: theme,
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
pickerModel: DateTimePickerModel(
currentTime: currentTime,
minTime: minTime,
@@ -157,15 +153,15 @@ class DatePicker {
///
/// Display date picker bottom sheet witch custom picker model.
///
- static Future showPicker(
+ static Future showPicker(
BuildContext context, {
- bool showTitleActions: true,
- DateChangedCallback onChanged,
- DateChangedCallback onConfirm,
- DateCancelledCallback onCancel,
- locale: LocaleType.en,
- BasePickerModel pickerModel,
- DatePickerTheme theme,
+ bool showTitleActions = true,
+ DateChangedCallback? onChanged,
+ DateChangedCallback? onConfirm,
+ DateCancelledCallback? onCancel,
+ LocaleType locale = LocaleType.en,
+ BasePickerModel? pickerModel,
+ DatePickerTheme? theme,
}) async {
return await Navigator.push(
context,
@@ -176,8 +172,7 @@ class DatePicker {
onCancel: onCancel,
locale: locale,
theme: theme,
- barrierLabel:
- MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
pickerModel: pickerModel,
),
);
@@ -190,22 +185,22 @@ class _DatePickerRoute extends PopupRoute {
this.onChanged,
this.onConfirm,
this.onCancel,
- theme,
+ DatePickerTheme? theme,
this.barrierLabel,
this.locale,
- RouteSettings settings,
- pickerModel,
- }) : this.pickerModel = pickerModel ?? DatePickerModel(),
- this.theme = theme ?? DatePickerTheme(),
+ RouteSettings? settings,
+ BasePickerModel? pickerModel,
+ }) : pickerModel = pickerModel ?? DatePickerModel(),
+ theme = theme ?? const DatePickerTheme(headerColor: Colors.transparent),
super(settings: settings);
- final bool showTitleActions;
- final DateChangedCallback onChanged;
- final DateChangedCallback onConfirm;
- final DateCancelledCallback onCancel;
- final DatePickerTheme theme;
- final LocaleType locale;
- final BasePickerModel pickerModel;
+ final bool? showTitleActions;
+ final DateChangedCallback? onChanged;
+ final DateChangedCallback? onConfirm;
+ final DateCancelledCallback? onCancel;
+ final DatePickerTheme? theme;
+ final LocaleType? locale;
+ final BasePickerModel? pickerModel;
@override
Duration get transitionDuration => const Duration(milliseconds: 200);
@@ -214,32 +209,30 @@ class _DatePickerRoute extends PopupRoute {
bool get barrierDismissible => true;
@override
- final String barrierLabel;
+ final String? barrierLabel;
@override
Color get barrierColor => Colors.black54;
- AnimationController _animationController;
+ AnimationController? _animationController;
@override
AnimationController createAnimationController() {
assert(_animationController == null);
- _animationController =
- BottomSheet.createAnimationController(navigator.overlay);
- return _animationController;
+ _animationController = BottomSheet.createAnimationController(navigator!.overlay!);
+ return _animationController!;
}
@override
- Widget buildPage(BuildContext context, Animation animation,
- Animation secondaryAnimation) {
- Widget bottomSheet = MediaQuery.removePadding(
+ Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) {
+ final Widget bottomSheet = MediaQuery.removePadding(
context: context,
removeTop: true,
child: _DatePickerComponent(
- onChanged: onChanged,
- locale: this.locale,
+ onChanged: onChanged!,
+ locale: locale!,
route: this,
- pickerModel: pickerModel,
+ pickerModel: pickerModel!,
),
);
return InheritedTheme.captureAll(context, bottomSheet);
@@ -248,20 +241,20 @@ class _DatePickerRoute extends PopupRoute {
class _DatePickerComponent extends StatefulWidget {
_DatePickerComponent({
- Key key,
+ Key? key,
@required this.route,
this.onChanged,
this.locale,
this.pickerModel,
}) : super(key: key);
- final DateChangedCallback onChanged;
+ final DateChangedCallback? onChanged;
- final _DatePickerRoute route;
+ final _DatePickerRoute? route;
- final LocaleType locale;
+ final LocaleType? locale;
- final BasePickerModel pickerModel;
+ final BasePickerModel? pickerModel;
@override
State createState() {
@@ -270,7 +263,7 @@ class _DatePickerComponent extends StatefulWidget {
}
class _DatePickerState extends State<_DatePickerComponent> {
- FixedExtentScrollController leftScrollCtrl, middleScrollCtrl, rightScrollCtrl;
+ late FixedExtentScrollController leftScrollCtrl, middleScrollCtrl, rightScrollCtrl;
@override
void initState() {
@@ -280,33 +273,30 @@ class _DatePickerState extends State<_DatePickerComponent> {
void refreshScrollOffset() {
// print('refreshScrollOffset ${widget.pickerModel.currentRightIndex()}');
- leftScrollCtrl = FixedExtentScrollController(
- initialItem: widget.pickerModel.currentLeftIndex());
- middleScrollCtrl = FixedExtentScrollController(
- initialItem: widget.pickerModel.currentMiddleIndex());
- rightScrollCtrl = FixedExtentScrollController(
- initialItem: widget.pickerModel.currentRightIndex());
+ leftScrollCtrl = FixedExtentScrollController(initialItem: widget.pickerModel!.currentLeftIndex()!);
+ middleScrollCtrl = FixedExtentScrollController(initialItem: widget.pickerModel!.currentMiddleIndex()!);
+ rightScrollCtrl = FixedExtentScrollController(initialItem: widget.pickerModel!.currentRightIndex()!);
}
@override
Widget build(BuildContext context) {
- DatePickerTheme theme = widget.route.theme;
+ final DatePickerTheme theme = widget.route!.theme!;
return GestureDetector(
child: AnimatedBuilder(
- animation: widget.route.animation,
- builder: (BuildContext context, Widget child) {
+ animation: widget.route!.animation!,
+ builder: (BuildContext context, Widget? child) {
final double bottomPadding = MediaQuery.of(context).padding.bottom;
return ClipRect(
child: CustomSingleChildLayout(
delegate: _BottomPickerLayout(
- widget.route.animation.value,
+ widget.route!.animation!.value,
theme,
- showTitleActions: widget.route.showTitleActions,
+ showTitleActions: widget.route!.showTitleActions!,
bottomPadding: bottomPadding,
),
child: GestureDetector(
child: Material(
- color: theme.backgroundColor ?? Colors.white,
+ color: theme.backgroundColor,
child: _renderPickerView(theme),
),
),
@@ -319,13 +309,13 @@ class _DatePickerState extends State<_DatePickerComponent> {
void _notifyDateChanged() {
if (widget.onChanged != null) {
- widget.onChanged(widget.pickerModel.finalTime());
+ widget.onChanged!(widget.pickerModel!.finalTime()!);
}
}
Widget _renderPickerView(DatePickerTheme theme) {
- Widget itemView = _renderItemView(theme);
- if (widget.route.showTitleActions) {
+ final Widget itemView = _renderItemView(theme);
+ if (widget.route!.showTitleActions!) {
return Column(
children: [
_renderTitleActionsView(theme),
@@ -337,8 +327,8 @@ class _DatePickerState extends State<_DatePickerComponent> {
}
Widget _renderColumnView(
- ValueKey key,
- DatePickerTheme theme,
+ ValueKey key,
+ DatePickerTheme? theme,
StringAtIndexCallBack stringAtIndexCB,
ScrollController scrollController,
int layoutProportion,
@@ -348,16 +338,16 @@ class _DatePickerState extends State<_DatePickerComponent> {
return Expanded(
flex: layoutProportion,
child: Container(
- padding: EdgeInsets.all(8.0),
- height: theme.containerHeight,
- decoration: BoxDecoration(color: theme.backgroundColor ?? Colors.white),
+ padding: const EdgeInsets.all(8.0),
+ height: theme!.containerHeight,
+ decoration: BoxDecoration(color: theme.backgroundColor),
child: NotificationListener(
onNotification: (ScrollNotification notification) {
if (notification.depth == 0 &&
selectedChangedWhenScrollEnd != null &&
notification is ScrollEndNotification &&
notification.metrics is FixedExtentMetrics) {
- final FixedExtentMetrics metrics = notification.metrics;
+ final FixedExtentMetrics metrics = notification.metrics as FixedExtentMetrics;
final int currentItemIndex = metrics.itemIndex;
selectedChangedWhenScrollEnd(currentItemIndex);
}
@@ -365,15 +355,15 @@ class _DatePickerState extends State<_DatePickerComponent> {
},
child: CupertinoPicker.builder(
key: key,
- backgroundColor: theme.backgroundColor ?? Colors.white,
- scrollController: scrollController,
+ backgroundColor: theme.backgroundColor,
+ scrollController: scrollController as FixedExtentScrollController,
itemExtent: theme.itemHeight,
onSelectedItemChanged: (int index) {
selectedChangedWhenScrolling(index);
},
useMagnifier: true,
itemBuilder: (BuildContext context, int index) {
- final content = stringAtIndexCB(index);
+ final String content = stringAtIndexCB(index)!;
if (content == null) {
return null;
}
@@ -395,20 +385,20 @@ class _DatePickerState extends State<_DatePickerComponent> {
Widget _renderItemView(DatePickerTheme theme) {
return Container(
- color: theme.backgroundColor ?? Colors.white,
+ color: theme.backgroundColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
- child: widget.pickerModel.layoutProportions()[0] > 0
+ child: widget.pickerModel!.layoutProportions()[0] > 0
? _renderColumnView(
- ValueKey(widget.pickerModel.currentLeftIndex()),
+ ValueKey(widget.pickerModel!.currentLeftIndex()!),
theme,
- widget.pickerModel.leftStringAtIndex,
+ widget.pickerModel!.leftStringAtIndex,
leftScrollCtrl,
- widget.pickerModel.layoutProportions()[0], (index) {
- widget.pickerModel.setLeftIndex(index);
- }, (index) {
+ widget.pickerModel!.layoutProportions()[0], (int index) {
+ widget.pickerModel!.setLeftIndex(index);
+ }, (int index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
@@ -417,19 +407,19 @@ class _DatePickerState extends State<_DatePickerComponent> {
: null,
),
Text(
- widget.pickerModel.leftDivider(),
+ widget.pickerModel!.leftDivider(),
style: theme.itemStyle,
),
Container(
- child: widget.pickerModel.layoutProportions()[1] > 0
+ child: widget.pickerModel!.layoutProportions()[1] > 0
? _renderColumnView(
- ValueKey(widget.pickerModel.currentLeftIndex()),
+ ValueKey(widget.pickerModel!.currentLeftIndex()!),
theme,
- widget.pickerModel.middleStringAtIndex,
+ widget.pickerModel!.middleStringAtIndex,
middleScrollCtrl,
- widget.pickerModel.layoutProportions()[1], (index) {
- widget.pickerModel.setMiddleIndex(index);
- }, (index) {
+ widget.pickerModel!.layoutProportions()[1], (int index) {
+ widget.pickerModel!.setMiddleIndex(index);
+ }, (int index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
@@ -438,20 +428,20 @@ class _DatePickerState extends State<_DatePickerComponent> {
: null,
),
Text(
- widget.pickerModel.rightDivider(),
+ widget.pickerModel!.rightDivider(),
style: theme.itemStyle,
),
Container(
- child: widget.pickerModel.layoutProportions()[2] > 0
+ child: widget.pickerModel!.layoutProportions()[2] > 0
? _renderColumnView(
- ValueKey(widget.pickerModel.currentMiddleIndex() * 100 +
- widget.pickerModel.currentLeftIndex()),
+ ValueKey(
+ widget.pickerModel!.currentMiddleIndex()! * 100 + widget.pickerModel!.currentLeftIndex()!),
theme,
- widget.pickerModel.rightStringAtIndex,
+ widget.pickerModel!.rightStringAtIndex,
rightScrollCtrl,
- widget.pickerModel.layoutProportions()[2], (index) {
- widget.pickerModel.setRightIndex(index);
- }, (index) {
+ widget.pickerModel!.layoutProportions()[2], (int index) {
+ widget.pickerModel!.setRightIndex(index);
+ }, (int index) {
setState(() {
refreshScrollOffset();
_notifyDateChanged();
@@ -466,13 +456,13 @@ class _DatePickerState extends State<_DatePickerComponent> {
// Title View
Widget _renderTitleActionsView(DatePickerTheme theme) {
- final done = _localeDone();
- final cancel = _localeCancel();
+ final String? done = _localeDone();
+ final String? cancel = _localeCancel();
return Container(
height: theme.titleHeight,
decoration: BoxDecoration(
- color: theme.headerColor ?? theme.backgroundColor ?? Colors.white,
+ color: theme.headerColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -481,15 +471,15 @@ class _DatePickerState extends State<_DatePickerComponent> {
height: theme.titleHeight,
child: CupertinoButton(
pressedOpacity: 0.3,
- padding: EdgeInsets.only(left: 16, top: 0),
+ padding: const EdgeInsets.only(left: 16, top: 0),
child: Text(
- '$cancel',
+ cancel!,
style: theme.cancelStyle,
),
onPressed: () {
Navigator.pop(context);
- if (widget.route.onCancel != null) {
- widget.route.onCancel();
+ if (widget.route!.onCancel != null) {
+ widget.route!.onCancel!();
}
},
),
@@ -498,15 +488,15 @@ class _DatePickerState extends State<_DatePickerComponent> {
height: theme.titleHeight,
child: CupertinoButton(
pressedOpacity: 0.3,
- padding: EdgeInsets.only(right: 16, top: 0),
+ padding: const EdgeInsets.only(right: 16, top: 0),
child: Text(
- '$done',
+ done!,
style: theme.doneStyle,
),
onPressed: () {
- Navigator.pop(context, widget.pickerModel.finalTime());
- if (widget.route.onConfirm != null) {
- widget.route.onConfirm(widget.pickerModel.finalTime());
+ Navigator.pop(context, widget.pickerModel!.finalTime());
+ if (widget.route!.onConfirm != null) {
+ widget.route!.onConfirm!(widget.pickerModel!.finalTime()!);
}
},
),
@@ -516,12 +506,12 @@ class _DatePickerState extends State<_DatePickerComponent> {
);
}
- String _localeDone() {
- return i18nObjInLocale(widget.locale)['done'];
+ String? _localeDone() {
+ return i18nObjInLocale(widget.locale!)!['done'] as String?;
}
- String _localeCancel() {
- return i18nObjInLocale(widget.locale)['cancel'];
+ String? _localeCancel() {
+ return i18nObjInLocale(widget.locale!)!['cancel'] as String?;
}
}
@@ -535,15 +525,15 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate {
});
final double progress;
- final int itemCount;
- final bool showTitleActions;
+ final int? itemCount;
+ final bool? showTitleActions;
final DatePickerTheme theme;
final double bottomPadding;
@override
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
double maxHeight = theme.containerHeight;
- if (showTitleActions) {
+ if (showTitleActions!) {
maxHeight += theme.titleHeight;
}
@@ -557,7 +547,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate {
@override
Offset getPositionForChild(Size size, Size childSize) {
- final height = size.height - childSize.height * progress;
+ final double height = size.height - childSize.height * progress;
return Offset(0.0, height);
}
diff --git a/lib/src/date_format.dart b/lib/src/date_format.dart
index c71ad42c..98c4f199 100755
--- a/lib/src/date_format.dart
+++ b/lib/src/date_format.dart
@@ -220,14 +220,13 @@ const String am = 'am';
const String z = 'z';
const String Z = 'Z';
-String formatDate(DateTime date, List formats, LocaleType locale) {
+String? formatDate(DateTime date, List formats, LocaleType locale) {
if (formats.first == ymdw) {
- final now = DateTime.now();
- if (date.year == now.year &&
- date.month == now.month &&
- date.day == now.day) {
+ final DateTime now = DateTime.now();
+ if (date.year == now.year && date.month == now.month && date.day == now.day) {
//today
- return i18nObjInLocale(locale)['today'];
+ final Map? map = i18nObjInLocale(locale);
+ return map!['today'] as String?;
} else if (date.year == now.year) {
if (locale == LocaleType.zh) {
return formatDate(date, [mm, '月', dd, '日 ', D], locale);
@@ -283,12 +282,10 @@ String formatDate(DateTime date, List formats, LocaleType locale) {
} else if (format == m) {
sb.write(date.month);
} else if (format == MM) {
- final monthLong =
- i18nObjInLocaleLookup(locale, 'monthLong', date.month - 1);
+ final monthLong = i18nObjInLocaleLookup(locale, 'monthLong', date.month - 1);
sb.write(monthLong);
} else if (format == M) {
- final monthShort =
- i18nObjInLocaleLookup(locale, 'monthShort', date.month - 1);
+ final monthShort = i18nObjInLocaleLookup(locale, 'monthShort', date.month - 1);
sb.write(monthShort);
} else if (format == dd) {
sb.write(digits(date.day, 2));
@@ -315,9 +312,7 @@ String formatDate(DateTime date, List formats, LocaleType locale) {
} else if (format == h) {
sb.write(date.hour % 12);
} else if (format == am) {
- sb.write(date.hour < 12
- ? i18nObjInLocale(locale)['am']
- : i18nObjInLocale(locale)['pm']);
+ sb.write(date.hour < 12 ? i18nObjInLocale(locale)!['am'] : i18nObjInLocale(locale)!['pm']);
} else if (format == nn) {
sb.write(digits(date.minute, 2));
} else if (format == n) {
@@ -362,5 +357,4 @@ String digits(int value, int length) {
return '$value'.padLeft(length, "0");
}
-int dayInYear(DateTime date) =>
- date.difference(new DateTime(date.year, 1, 1)).inDays;
+int dayInYear(DateTime date) => date.difference(new DateTime(date.year, 1, 1)).inDays;
diff --git a/lib/src/date_model.dart b/lib/src/date_model.dart
index 7f22b746..d9fc84be 100644
--- a/lib/src/date_model.dart
+++ b/lib/src/date_model.dart
@@ -6,74 +6,86 @@ import 'dart:math';
//interface for picker data model
abstract class BasePickerModel {
//a getter method for left column data, return null to end list
- String leftStringAtIndex(int index);
+ String? leftStringAtIndex(int index);
+
//a getter method for middle column data, return null to end list
- String middleStringAtIndex(int index);
+ String? middleStringAtIndex(int index);
+
//a getter method for right column data, return null to end list
- String rightStringAtIndex(int index);
+ String? rightStringAtIndex(int index);
+
//set selected left index
void setLeftIndex(int index);
+
//set selected middle index
void setMiddleIndex(int index);
+
//set selected right index
void setRightIndex(int index);
+
//return current left index
- int currentLeftIndex();
+ int? currentLeftIndex();
+
//return current middle index
- int currentMiddleIndex();
+ int? currentMiddleIndex();
+
//return current right index
- int currentRightIndex();
+ int? currentRightIndex();
+
//return final time
- DateTime finalTime();
+ DateTime? finalTime();
+
//return left divider string
String leftDivider();
+
//return right divider string
String rightDivider();
+
//layout proportions for 3 columns
List layoutProportions();
}
//a base class for picker data model
class CommonPickerModel extends BasePickerModel {
- List leftList;
- List middleList;
- List rightList;
- DateTime currentTime;
- int _currentLeftIndex;
- int _currentMiddleIndex;
- int _currentRightIndex;
+ CommonPickerModel({this.currentTime, LocaleType? locale}) : locale = locale ?? LocaleType.en;
- LocaleType locale;
+ List? leftList;
+ List? middleList;
+ List? rightList;
+ DateTime? currentTime;
+ int? _currentLeftIndex;
+ int? _currentMiddleIndex;
+ int? _currentRightIndex;
- CommonPickerModel({this.currentTime, locale}) : this.locale = locale ?? LocaleType.en;
+ LocaleType? locale;
@override
- String leftStringAtIndex(int index) {
+ String? leftStringAtIndex(int index) {
return null;
}
@override
- String middleStringAtIndex(int index) {
+ String? middleStringAtIndex(int index) {
return null;
}
@override
- String rightStringAtIndex(int index) {
+ String? rightStringAtIndex(int index) {
return null;
}
@override
- int currentLeftIndex() {
+ int? currentLeftIndex() {
return _currentLeftIndex;
}
@override
- int currentMiddleIndex() {
+ int? currentMiddleIndex() {
return _currentMiddleIndex;
}
@override
- int currentRightIndex() {
+ int? currentRightIndex() {
return _currentRightIndex;
}
@@ -94,12 +106,12 @@ class CommonPickerModel extends BasePickerModel {
@override
String leftDivider() {
- return "";
+ return '';
}
@override
String rightDivider() {
- return "";
+ return '';
}
@override
@@ -108,26 +120,26 @@ class CommonPickerModel extends BasePickerModel {
}
@override
- DateTime finalTime() {
+ DateTime? finalTime() {
return null;
}
}
//a date picker model
class DatePickerModel extends CommonPickerModel {
- DateTime maxTime;
- DateTime minTime;
+ DateTime? maxTime;
+ DateTime? minTime;
- DatePickerModel({DateTime currentTime, DateTime maxTime, DateTime minTime, LocaleType locale})
+ DatePickerModel({DateTime? currentTime, DateTime? maxTime, DateTime? minTime, LocaleType? locale})
: super(locale: locale) {
this.maxTime = maxTime ?? DateTime(2049, 12, 31);
this.minTime = minTime ?? DateTime(1970, 1, 1);
currentTime = currentTime ?? DateTime.now();
if (currentTime != null) {
- if (currentTime.compareTo(this.maxTime) > 0) {
+ if (currentTime.compareTo(this.maxTime!) > 0) {
currentTime = this.maxTime;
- } else if (currentTime.compareTo(this.minTime) < 0) {
+ } else if (currentTime.compareTo(this.minTime!) < 0) {
currentTime = this.minTime;
}
}
@@ -136,52 +148,50 @@ class DatePickerModel extends CommonPickerModel {
_fillLeftLists();
_fillMiddleLists();
_fillRightLists();
- int minMonth = _minMonthOfCurrentYear();
- int minDay = _minDayOfCurrentMonth();
- _currentLeftIndex = this.currentTime.year - this.minTime.year;
- _currentMiddleIndex = this.currentTime.month - minMonth;
- _currentRightIndex = this.currentTime.day - minDay;
+ final int minMonth = _minMonthOfCurrentYear();
+ final int minDay = _minDayOfCurrentMonth();
+ _currentLeftIndex = this.currentTime!.year - this.minTime!.year;
+ _currentMiddleIndex = this.currentTime!.month - minMonth;
+ _currentRightIndex = this.currentTime!.day - minDay;
}
void _fillLeftLists() {
- this.leftList = List.generate(maxTime.year - minTime.year + 1, (int index) {
+ leftList = List.generate(maxTime!.year - minTime!.year + 1, (int index) {
// print('LEFT LIST... ${minTime.year + index}${_localeYear()}');
- return '${minTime.year + index}${_localeYear()}';
+ return '${minTime!.year + index}${_localeYear()}';
});
}
int _maxMonthOfCurrentYear() {
- return currentTime.year == maxTime.year ? maxTime.month : 12;
+ return currentTime!.year == maxTime!.year ? maxTime!.month : 12;
}
int _minMonthOfCurrentYear() {
- return currentTime.year == minTime.year ? minTime.month : 1;
+ return currentTime!.year == minTime!.year ? minTime!.month : 1;
}
int _maxDayOfCurrentMonth() {
- int dayCount = calcDateCount(currentTime.year, currentTime.month);
- return currentTime.year == maxTime.year && currentTime.month == maxTime.month
- ? maxTime.day
- : dayCount;
+ final int dayCount = calcDateCount(currentTime!.year, currentTime!.month);
+ return currentTime!.year == maxTime!.year && currentTime!.month == maxTime!.month ? maxTime!.day : dayCount;
}
int _minDayOfCurrentMonth() {
- return currentTime.year == minTime.year && currentTime.month == minTime.month ? minTime.day : 1;
+ return currentTime!.year == minTime!.year && currentTime!.month == minTime!.month ? minTime!.day : 1;
}
void _fillMiddleLists() {
- int minMonth = _minMonthOfCurrentYear();
- int maxMonth = _maxMonthOfCurrentYear();
+ final int minMonth = _minMonthOfCurrentYear();
+ final int maxMonth = _maxMonthOfCurrentYear();
- this.middleList = List.generate(maxMonth - minMonth + 1, (int index) {
- return '${_localeMonth(minMonth + index)}';
+ middleList = List.generate(maxMonth - minMonth + 1, (int index) {
+ return _localeMonth(minMonth + index);
});
}
void _fillRightLists() {
- int maxDay = _maxDayOfCurrentMonth();
- int minDay = _minDayOfCurrentMonth();
- this.rightList = List.generate(maxDay - minDay + 1, (int index) {
+ final int maxDay = _maxDayOfCurrentMonth();
+ final int minDay = _minDayOfCurrentMonth();
+ rightList = List.generate(maxDay - minDay + 1, (int index) {
return '${minDay + index}${_localeDay()}';
});
}
@@ -190,39 +200,39 @@ class DatePickerModel extends CommonPickerModel {
void setLeftIndex(int index) {
super.setLeftIndex(index);
//adjust middle
- int destYear = index + minTime.year;
+ final int destYear = index + minTime!.year;
int minMonth = _minMonthOfCurrentYear();
DateTime newTime;
//change date time
- if (currentTime.month == 2 && currentTime.day == 29) {
- newTime = currentTime.isUtc
+ if (currentTime!.month == 2 && currentTime!.day == 29) {
+ newTime = currentTime!.isUtc
? DateTime.utc(
destYear,
- currentTime.month,
+ currentTime!.month,
calcDateCount(destYear, 2),
)
: DateTime(
destYear,
- currentTime.month,
+ currentTime!.month,
calcDateCount(destYear, 2),
);
} else {
- newTime = currentTime.isUtc
+ newTime = currentTime!.isUtc
? DateTime.utc(
destYear,
- currentTime.month,
- currentTime.day,
+ currentTime!.month,
+ currentTime!.day,
)
: DateTime(
destYear,
- currentTime.month,
- currentTime.day,
+ currentTime!.month,
+ currentTime!.day,
);
}
//min/max check
- if (newTime.isAfter(maxTime)) {
+ if (newTime.isAfter(maxTime!)) {
currentTime = maxTime;
- } else if (newTime.isBefore(minTime)) {
+ } else if (newTime.isBefore(minTime!)) {
currentTime = minTime;
} else {
currentTime = newTime;
@@ -231,84 +241,84 @@ class DatePickerModel extends CommonPickerModel {
_fillMiddleLists();
_fillRightLists();
minMonth = _minMonthOfCurrentYear();
- int minDay = _minDayOfCurrentMonth();
- _currentMiddleIndex = currentTime.month - minMonth;
- _currentRightIndex = currentTime.day - minDay;
+ final int minDay = _minDayOfCurrentMonth();
+ _currentMiddleIndex = currentTime!.month - minMonth;
+ _currentRightIndex = currentTime!.day - minDay;
}
@override
void setMiddleIndex(int index) {
super.setMiddleIndex(index);
//adjust right
- int minMonth = _minMonthOfCurrentYear();
- int destMonth = minMonth + index;
+ final int minMonth = _minMonthOfCurrentYear();
+ final int destMonth = minMonth + index;
DateTime newTime;
//change date time
- int dayCount = calcDateCount(currentTime.year, destMonth);
- newTime = currentTime.isUtc
+ final int dayCount = calcDateCount(currentTime!.year, destMonth);
+ newTime = currentTime!.isUtc
? DateTime.utc(
- currentTime.year,
+ currentTime!.year,
destMonth,
- currentTime.day <= dayCount ? currentTime.day : dayCount,
+ currentTime!.day <= dayCount ? currentTime!.day : dayCount,
)
: DateTime(
- currentTime.year,
+ currentTime!.year,
destMonth,
- currentTime.day <= dayCount ? currentTime.day : dayCount,
+ currentTime!.day <= dayCount ? currentTime!.day : dayCount,
);
//min/max check
- if (newTime.isAfter(maxTime)) {
+ if (newTime.isAfter(maxTime!)) {
currentTime = maxTime;
- } else if (newTime.isBefore(minTime)) {
+ } else if (newTime.isBefore(minTime!)) {
currentTime = minTime;
} else {
currentTime = newTime;
}
_fillRightLists();
- int minDay = _minDayOfCurrentMonth();
- _currentRightIndex = currentTime.day - minDay;
+ final int minDay = _minDayOfCurrentMonth();
+ _currentRightIndex = currentTime!.day - minDay;
}
@override
void setRightIndex(int index) {
super.setRightIndex(index);
- int minDay = _minDayOfCurrentMonth();
- currentTime = currentTime.isUtc
+ final int minDay = _minDayOfCurrentMonth();
+ currentTime = currentTime!.isUtc
? DateTime.utc(
- currentTime.year,
- currentTime.month,
+ currentTime!.year,
+ currentTime!.month,
minDay + index,
)
: DateTime(
- currentTime.year,
- currentTime.month,
+ currentTime!.year,
+ currentTime!.month,
minDay + index,
);
}
@override
- String leftStringAtIndex(int index) {
- if (index >= 0 && index < leftList.length) {
- return leftList[index];
+ String? leftStringAtIndex(int index) {
+ if (index >= 0 && index < leftList!.length) {
+ return leftList![index];
} else {
return null;
}
}
@override
- String middleStringAtIndex(int index) {
- if (index >= 0 && index < middleList.length) {
- return middleList[index];
+ String? middleStringAtIndex(int index) {
+ if (index >= 0 && index < middleList!.length) {
+ return middleList![index];
} else {
return null;
}
}
@override
- String rightStringAtIndex(int index) {
- if (index >= 0 && index < rightList.length) {
- return rightList[index];
+ String? rightStringAtIndex(int index) {
+ if (index >= 0 && index < rightList!.length) {
+ return rightList![index];
} else {
return null;
}
@@ -330,7 +340,7 @@ class DatePickerModel extends CommonPickerModel {
} else if (locale == LocaleType.ko) {
return '$month월';
} else {
- List monthStrings = i18nObjInLocale(locale)['monthLong'];
+ final List monthStrings = i18nObjInLocale(locale!)!['monthLong']! as List;
return monthStrings[month - 1];
}
}
@@ -346,7 +356,7 @@ class DatePickerModel extends CommonPickerModel {
}
@override
- DateTime finalTime() {
+ DateTime? finalTime() {
return currentTime;
}
}
@@ -355,17 +365,16 @@ class DatePickerModel extends CommonPickerModel {
class TimePickerModel extends CommonPickerModel {
bool showSecondsColumn;
- TimePickerModel({DateTime currentTime, LocaleType locale, this.showSecondsColumn: true})
- : super(locale: locale) {
+ TimePickerModel({DateTime? currentTime, LocaleType? locale, this.showSecondsColumn = true}) : super(locale: locale) {
this.currentTime = currentTime ?? DateTime.now();
- _currentLeftIndex = this.currentTime.hour;
- _currentMiddleIndex = this.currentTime.minute;
- _currentRightIndex = this.currentTime.second;
+ _currentLeftIndex = this.currentTime!.hour;
+ _currentMiddleIndex = this.currentTime!.minute;
+ _currentRightIndex = this.currentTime!.second;
}
@override
- String leftStringAtIndex(int index) {
+ String? leftStringAtIndex(int index) {
if (index >= 0 && index < 24) {
return digits(index, 2);
} else {
@@ -374,7 +383,7 @@ class TimePickerModel extends CommonPickerModel {
}
@override
- String middleStringAtIndex(int index) {
+ String? middleStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return digits(index, 2);
} else {
@@ -383,7 +392,7 @@ class TimePickerModel extends CommonPickerModel {
}
@override
- String rightStringAtIndex(int index) {
+ String? rightStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return digits(index, 2);
} else {
@@ -393,15 +402,15 @@ class TimePickerModel extends CommonPickerModel {
@override
String leftDivider() {
- return ":";
+ return ':';
}
@override
String rightDivider() {
if (showSecondsColumn)
- return ":";
+ return ':';
else
- return "";
+ return '';
}
@override
@@ -414,26 +423,26 @@ class TimePickerModel extends CommonPickerModel {
@override
DateTime finalTime() {
- return currentTime.isUtc
- ? DateTime.utc(currentTime.year, currentTime.month, currentTime.day, _currentLeftIndex,
- _currentMiddleIndex, _currentRightIndex)
- : DateTime(currentTime.year, currentTime.month, currentTime.day, _currentLeftIndex,
- _currentMiddleIndex, _currentRightIndex);
+ return currentTime!.isUtc
+ ? DateTime.utc(currentTime!.year, currentTime!.month, currentTime!.day, _currentLeftIndex!,
+ _currentMiddleIndex!, _currentRightIndex!)
+ : DateTime(currentTime!.year, currentTime!.month, currentTime!.day, _currentLeftIndex!, _currentMiddleIndex!,
+ _currentRightIndex!);
}
}
//a time picker model
class Time12hPickerModel extends CommonPickerModel {
- Time12hPickerModel({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
+ Time12hPickerModel({DateTime? currentTime, LocaleType? locale}) : super(locale: locale) {
this.currentTime = currentTime ?? DateTime.now();
- _currentLeftIndex = this.currentTime.hour % 12;
- _currentMiddleIndex = this.currentTime.minute;
- _currentRightIndex = this.currentTime.hour < 12 ? 0 : 1;
+ _currentLeftIndex = this.currentTime!.hour % 12;
+ _currentMiddleIndex = this.currentTime!.minute;
+ _currentRightIndex = this.currentTime!.hour < 12 ? 0 : 1;
}
@override
- String leftStringAtIndex(int index) {
+ String? leftStringAtIndex(int index) {
if (index >= 0 && index < 12) {
if (index == 0) {
return digits(12, 2);
@@ -446,7 +455,7 @@ class Time12hPickerModel extends CommonPickerModel {
}
@override
- String middleStringAtIndex(int index) {
+ String? middleStringAtIndex(int index) {
if (index >= 0 && index < 60) {
return digits(index, 2);
} else {
@@ -455,11 +464,11 @@ class Time12hPickerModel extends CommonPickerModel {
}
@override
- String rightStringAtIndex(int index) {
+ String? rightStringAtIndex(int index) {
if (index == 0) {
- return i18nObjInLocale(this.locale)["am"];
+ return i18nObjInLocale(locale!)!['am']! as String;
} else if (index == 1) {
- return i18nObjInLocale(this.locale)["pm"];
+ return i18nObjInLocale(locale!)!['pm']! as String;
} else {
return null;
}
@@ -467,12 +476,12 @@ class Time12hPickerModel extends CommonPickerModel {
@override
String leftDivider() {
- return ":";
+ return ':';
}
@override
String rightDivider() {
- return ":";
+ return ':';
}
@override
@@ -482,66 +491,60 @@ class Time12hPickerModel extends CommonPickerModel {
@override
DateTime finalTime() {
- int hour = _currentLeftIndex + 12 * _currentRightIndex;
- return currentTime.isUtc
- ? DateTime.utc(
- currentTime.year, currentTime.month, currentTime.day, hour, _currentMiddleIndex, 0)
- : DateTime(
- currentTime.year, currentTime.month, currentTime.day, hour, _currentMiddleIndex, 0);
+ final int hour = _currentLeftIndex! + 12 * _currentRightIndex!;
+ return currentTime!.isUtc
+ ? DateTime.utc(currentTime!.year, currentTime!.month, currentTime!.day, hour, _currentMiddleIndex!, 0)
+ : DateTime(currentTime!.year, currentTime!.month, currentTime!.day, hour, _currentMiddleIndex!, 0);
}
}
// a date&time picker model
class DateTimePickerModel extends CommonPickerModel {
- DateTime maxTime;
- DateTime minTime;
- DateTimePickerModel({DateTime currentTime, DateTime maxTime, DateTime minTime, LocaleType locale})
+ DateTime? maxTime;
+ DateTime? minTime;
+
+ DateTimePickerModel({DateTime? currentTime, DateTime? maxTime, DateTime? minTime, LocaleType? locale})
: super(locale: locale) {
if (currentTime != null) {
this.currentTime = currentTime;
- if (maxTime != null &&
- (currentTime.isBefore(maxTime) || currentTime.isAtSameMomentAs(maxTime))) {
+ if (maxTime != null && (currentTime.isBefore(maxTime) || currentTime.isAtSameMomentAs(maxTime))) {
this.maxTime = maxTime;
}
- if (minTime != null &&
- (currentTime.isAfter(minTime) || currentTime.isAtSameMomentAs(minTime))) {
+ if (minTime != null && (currentTime.isAfter(minTime) || currentTime.isAtSameMomentAs(minTime))) {
this.minTime = minTime;
}
} else {
- this.maxTime = maxTime;
- this.minTime = minTime;
- var now = DateTime.now();
- if (this.minTime != null && this.minTime.isAfter(now)) {
+ this.maxTime = maxTime!;
+ this.minTime = minTime!;
+ final DateTime now = DateTime.now();
+ if (this.minTime != null && this.minTime!.isAfter(now)) {
this.currentTime = this.minTime;
- } else if (this.maxTime != null && this.maxTime.isBefore(now)) {
+ } else if (this.maxTime != null && this.maxTime!.isBefore(now)) {
this.currentTime = this.maxTime;
} else {
this.currentTime = now;
}
}
- if (this.minTime != null && this.maxTime != null && this.maxTime.isBefore(this.minTime)) {
+ if (this.minTime != null && this.maxTime != null && this.maxTime!.isBefore(this.minTime!)) {
// invalid
this.minTime = null;
this.maxTime = null;
}
_currentLeftIndex = 0;
- _currentMiddleIndex = this.currentTime.hour;
- _currentRightIndex = this.currentTime.minute;
- if (this.minTime != null && isAtSameDay(this.minTime, this.currentTime)) {
- _currentMiddleIndex = this.currentTime.hour - this.minTime.hour;
+ _currentMiddleIndex = this.currentTime!.hour;
+ _currentRightIndex = this.currentTime!.minute;
+ if (this.minTime != null && isAtSameDay(this.minTime!, this.currentTime!)) {
+ _currentMiddleIndex = this.currentTime!.hour - this.minTime!.hour;
if (_currentMiddleIndex == 0) {
- _currentRightIndex = this.currentTime.minute - this.minTime.minute;
+ _currentRightIndex = this.currentTime!.minute - this.minTime!.minute;
}
}
}
bool isAtSameDay(DateTime day1, DateTime day2) {
- return day1 != null &&
- day2 != null &&
- day1.difference(day2).inDays == 0 &&
- day1.day == day2.day;
+ return day1 != null && day2 != null && day1.difference(day2).inDays == 0 && day1.day == day2.day;
}
@override
@@ -549,13 +552,13 @@ class DateTimePickerModel extends CommonPickerModel {
// TODO: implement setLeftIndex
super.setLeftIndex(index);
- DateTime time = currentTime.add(Duration(days: index));
- if (isAtSameDay(minTime, time)) {
- var index = min(24 - minTime.hour - 1, _currentMiddleIndex);
- this.setMiddleIndex(index);
- } else if (isAtSameDay(maxTime, time)) {
- var index = min(maxTime.hour, _currentMiddleIndex);
- this.setMiddleIndex(index);
+ final DateTime time = currentTime!.add(Duration(days: index));
+ if (isAtSameDay(minTime!, time)) {
+ final int index = min(24 - minTime!.hour - 1, _currentMiddleIndex!);
+ setMiddleIndex(index);
+ } else if (isAtSameDay(maxTime!, time)) {
+ final int index = min(maxTime!.hour, _currentMiddleIndex!);
+ setMiddleIndex(index);
}
}
@@ -563,43 +566,43 @@ class DateTimePickerModel extends CommonPickerModel {
void setMiddleIndex(int index) {
// TODO: implement setMiddleIndex
super.setMiddleIndex(index);
- DateTime time = currentTime.add(Duration(days: _currentLeftIndex));
- if (isAtSameDay(minTime, time) && index == 0) {
- var maxIndex = 60 - minTime.minute - 1;
- if (_currentRightIndex > maxIndex) {
+ final DateTime time = currentTime!.add(Duration(days: _currentLeftIndex!));
+ if (isAtSameDay(minTime!, time) && index == 0) {
+ final int maxIndex = 60 - minTime!.minute - 1;
+ if (_currentRightIndex! > maxIndex) {
_currentRightIndex = maxIndex;
}
- } else if (isAtSameDay(maxTime, time) && _currentMiddleIndex == maxTime.hour) {
- var maxIndex = maxTime.minute;
- if (_currentRightIndex > maxIndex) {
+ } else if (isAtSameDay(maxTime!, time) && _currentMiddleIndex == maxTime!.hour) {
+ final int maxIndex = maxTime!.minute;
+ if (_currentRightIndex! > maxIndex) {
_currentRightIndex = maxIndex;
}
}
}
@override
- String leftStringAtIndex(int index) {
- DateTime time = currentTime.add(Duration(days: index));
- if (minTime != null && time.isBefore(minTime) && !isAtSameDay(minTime, time)) {
+ String? leftStringAtIndex(int index) {
+ final DateTime time = currentTime!.add(Duration(days: index));
+ if (minTime != null && time.isBefore(minTime!) && !isAtSameDay(minTime!, time)) {
return null;
- } else if (maxTime != null && time.isAfter(maxTime) && !isAtSameDay(maxTime, time)) {
+ } else if (maxTime != null && time.isAfter(maxTime!) && !isAtSameDay(maxTime!, time)) {
return null;
}
- return formatDate(time, [ymdw], locale);
+ return formatDate(time, [ymdw], locale!);
}
@override
- String middleStringAtIndex(int index) {
+ String? middleStringAtIndex(int index) {
if (index >= 0 && index < 24) {
- DateTime time = currentTime.add(Duration(days: _currentLeftIndex));
- if (isAtSameDay(minTime, time)) {
- if (index >= 0 && index < 24 - minTime.hour) {
- return digits(minTime.hour + index, 2);
+ final DateTime time = currentTime!.add(Duration(days: _currentLeftIndex!));
+ if (isAtSameDay(minTime!, time)) {
+ if (index >= 0 && index < 24 - minTime!.hour) {
+ return digits(minTime!.hour + index, 2);
} else {
return null;
}
- } else if (isAtSameDay(maxTime, time)) {
- if (index >= 0 && index <= maxTime.hour) {
+ } else if (isAtSameDay(maxTime!, time)) {
+ if (index >= 0 && index <= maxTime!.hour) {
return digits(index, 2);
} else {
return null;
@@ -612,17 +615,17 @@ class DateTimePickerModel extends CommonPickerModel {
}
@override
- String rightStringAtIndex(int index) {
+ String? rightStringAtIndex(int index) {
if (index >= 0 && index < 60) {
- DateTime time = currentTime.add(Duration(days: _currentLeftIndex));
- if (isAtSameDay(minTime, time) && _currentMiddleIndex == 0) {
- if (index >= 0 && index < 60 - minTime.minute) {
- return digits(minTime.minute + index, 2);
+ final DateTime time = currentTime!.add(Duration(days: _currentLeftIndex!));
+ if (isAtSameDay(minTime!, time) && _currentMiddleIndex == 0) {
+ if (index >= 0 && index < 60 - minTime!.minute) {
+ return digits(minTime!.minute + index, 2);
} else {
return null;
}
- } else if (isAtSameDay(maxTime, time) && _currentMiddleIndex >= maxTime.hour) {
- if (index >= 0 && index <= maxTime.minute) {
+ } else if (isAtSameDay(maxTime!, time) && _currentMiddleIndex! >= maxTime!.hour) {
+ if (index >= 0 && index <= maxTime!.minute) {
return digits(index, 2);
} else {
return null;
@@ -636,17 +639,17 @@ class DateTimePickerModel extends CommonPickerModel {
@override
DateTime finalTime() {
- DateTime time = currentTime.add(Duration(days: _currentLeftIndex));
- var hour = _currentMiddleIndex;
- var minute = _currentRightIndex;
- if (isAtSameDay(minTime, time)) {
- hour += minTime.hour;
- if (minTime.hour == hour) {
- minute += minTime.minute;
+ final DateTime time = currentTime!.add(Duration(days: _currentLeftIndex!));
+ int hour = _currentMiddleIndex!;
+ int minute = _currentRightIndex!;
+ if (isAtSameDay(minTime!, time)) {
+ hour += minTime!.hour;
+ if (minTime!.hour == hour) {
+ minute += minTime!.minute;
}
}
- return currentTime.isUtc
+ return currentTime!.isUtc
? DateTime.utc(time.year, time.month, time.day, hour, minute)
: DateTime(time.year, time.month, time.day, hour, minute);
}
diff --git a/lib/src/datetime_picker_theme.dart b/lib/src/datetime_picker_theme.dart
index f98e2752..b66daf76 100644
--- a/lib/src/datetime_picker_theme.dart
+++ b/lib/src/datetime_picker_theme.dart
@@ -19,7 +19,7 @@ class DatePickerTheme with DiagnosticableTreeMixin {
this.doneStyle = const TextStyle(color: Colors.blue, fontSize: 16),
this.itemStyle = const TextStyle(color: Color(0xFF000046), fontSize: 18),
this.backgroundColor = Colors.white,
- this.headerColor,
+ required this.headerColor,
this.containerHeight = 210.0,
this.titleHeight = 44.0,
this.itemHeight = 36.0,
diff --git a/lib/src/i18n_model.dart b/lib/src/i18n_model.dart
index 248de956..f73947c3 100644
--- a/lib/src/i18n_model.dart
+++ b/lib/src/i18n_model.dart
@@ -76,20 +76,7 @@ final _i18nModel = >{
'cancel': 'Cancel',
'done': 'Done',
'today': 'Today',
- 'monthShort': [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'May',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec'
- ],
+ 'monthShort': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'monthLong': [
'January',
'February',
@@ -176,15 +163,7 @@ final _i18nModel = >{
'آبان',
'آذر',
],
- 'day': [
- 'دوشنبه',
- 'سه شنبه',
- 'چهارشنبه',
- 'پنج شنبه',
- 'جمعه',
- 'شنبه',
- 'یکشنبه'
- ],
+ 'day': ['دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنج شنبه', 'جمعه', 'شنبه', 'یکشنبه'],
'am': 'صبح',
'pm': 'عصر'
},
@@ -193,34 +172,8 @@ final _i18nModel = >{
'cancel': '取消',
'done': '确定',
'today': '今天',
- 'monthShort': [
- '一月',
- '二月',
- '三月',
- '四月',
- '五月',
- '六月',
- '七月',
- '八月',
- '九月',
- '十月',
- '十一月',
- '十二月'
- ],
- 'monthLong': [
- '一月',
- '二月',
- '三月',
- '四月',
- '五月',
- '六月',
- '七月',
- '八月',
- '九月',
- '十月',
- '十一月',
- '十二月'
- ],
+ 'monthShort': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+ 'monthLong': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'day': ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'],
'am': '上午',
'pm': '下午'
@@ -230,34 +183,8 @@ final _i18nModel = >{
'cancel': '取消',
'done': '確定',
'today': '今天',
- 'monthShort': [
- '一月',
- '二月',
- '三月',
- '四月',
- '五月',
- '六月',
- '七月',
- '八月',
- '九月',
- '十月',
- '十一月',
- '十二月'
- ],
- 'monthLong': [
- '一月',
- '二月',
- '三月',
- '四月',
- '五月',
- '六月',
- '七月',
- '八月',
- '九月',
- '十月',
- '十一月',
- '十二月'
- ],
+ 'monthShort': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+ 'monthLong': ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'day': ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'],
'am': '上午',
'pm': '下午'
@@ -311,20 +238,7 @@ final _i18nModel = >{
'cancel': 'Отмена',
'done': 'Готово',
'today': 'Сегодня',
- 'monthShort': [
- 'Янв',
- 'Фев',
- 'Март',
- 'Апр',
- 'Май',
- 'Июнь',
- 'Июль',
- 'Авг',
- 'Сен',
- 'Окт',
- 'Ноя',
- 'Дек'
- ],
+ 'monthShort': ['Янв', 'Фев', 'Март', 'Апр', 'Май', 'Июнь', 'Июль', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'],
'monthLong': [
'Январь',
'Февраль',
@@ -347,20 +261,7 @@ final _i18nModel = >{
'cancel': 'Annulla',
'done': 'Conferma',
'today': 'Oggi',
- 'monthShort': [
- 'Gen',
- 'Feb',
- 'Mar',
- 'Apr',
- 'Mag',
- 'Giu',
- 'Lug',
- 'Ago',
- 'Set',
- 'Ott',
- 'Nov',
- 'Dic'
- ],
+ 'monthShort': ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
'monthLong': [
'Gennaio',
'Febbraio',
@@ -383,20 +284,7 @@ final _i18nModel = >{
'cancel': 'Annuler',
'done': 'Confirmer',
'today': "Aujourd'hui",
- 'monthShort': [
- 'Jan',
- 'Fév',
- 'Mar',
- 'Avr',
- 'Mai',
- 'Juin',
- 'Juil',
- 'Aoû',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Déc'
- ],
+ 'monthShort': ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc'],
'monthLong': [
'Janvier',
'Février',
@@ -419,20 +307,7 @@ final _i18nModel = >{
'cancel': 'Άκυρο',
'done': 'Επιβεβαίωση',
'today': 'Σήμερα',
- 'monthShort': [
- 'Ιαν',
- 'Φεβρ',
- 'Μάρτ',
- 'Απρ',
- 'Μάι',
- 'Ιούν',
- 'Ιούλ',
- 'Αύγ',
- 'Σεπτ',
- 'Οκτ',
- 'Νοέμβρ',
- 'Δεκ'
- ],
+ 'monthShort': ['Ιαν', 'Φεβρ', 'Μάρτ', 'Απρ', 'Μάι', 'Ιούν', 'Ιούλ', 'Αύγ', 'Σεπτ', 'Οκτ', 'Νοέμβρ', 'Δεκ'],
'monthLong': [
'Ιανουάριος',
'Φεβρουάριος',
@@ -455,20 +330,7 @@ final _i18nModel = >{
'cancel': 'Cancelar',
'done': 'Confirmar',
'today': 'Hoy',
- 'monthShort': [
- 'Ene',
- 'Feb',
- 'Mar',
- 'Abr',
- 'May',
- 'Jun',
- 'Jul',
- 'Ago',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dic'
- ],
+ 'monthShort': ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
'monthLong': [
'Enero',
'Febrero',
@@ -491,20 +353,7 @@ final _i18nModel = >{
'cancel': 'Anuluj',
'done': 'Gotowe',
'today': 'Dziś',
- 'monthShort': [
- 'Sty',
- 'Lut',
- 'Mar',
- 'Kwi',
- 'Maj',
- 'Cze',
- 'Lip',
- 'Sie',
- 'Wrz',
- 'Paź',
- 'Lis',
- 'Gru'
- ],
+ 'monthShort': ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'],
'monthLong': [
'Styczeń',
'Luty',
@@ -527,20 +376,7 @@ final _i18nModel = >{
'cancel': 'Cancelar',
'done': 'Confirmar',
'today': 'Hoje',
- 'monthShort': [
- 'Jan',
- 'Fev',
- 'Mar',
- 'Abr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Ago',
- 'Set',
- 'Out',
- 'Nov',
- 'Dez'
- ],
+ 'monthShort': ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
'monthLong': [
'Janeiro',
'Fevereiro',
@@ -563,34 +399,8 @@ final _i18nModel = >{
'cancel': '취소',
'done': '완료',
'today': '오늘',
- 'monthShort': [
- '1월',
- '2월',
- '3월',
- '4월',
- '5월',
- '6월',
- '7월',
- '8월',
- '9월',
- '10월',
- '11월',
- '12월'
- ],
- 'monthLong': [
- '1월',
- '2월',
- '3월',
- '4월',
- '5월',
- '6월',
- '7월',
- '8월',
- '9월',
- '10월',
- '11월',
- '12월'
- ],
+ 'monthShort': ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
+ 'monthLong': ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
'day': ['월', '화', '수', '목', '금', '토', '일'],
'am': '오전',
'pm': '오후'
@@ -599,20 +409,7 @@ final _i18nModel = >{
'cancel': 'Жою',
'done': 'Дайын',
'today': 'бүгін',
- 'monthShort': [
- 'Қаң',
- 'Ақп',
- 'Нау',
- 'Сәу',
- 'Мам',
- 'Мау',
- 'Шіл',
- 'Там',
- 'Қыр',
- 'Қаз',
- 'Қар',
- 'Жел'
- ],
+ 'monthShort': ['Қаң', 'Ақп', 'Нау', 'Сәу', 'Мам', 'Мау', 'Шіл', 'Там', 'Қыр', 'Қаз', 'Қар', 'Жел'],
'monthLong': [
'Қаңтар',
'Ақпан',
@@ -663,15 +460,7 @@ final _i18nModel = >{
'نوفمبر',
'ديسمبر'
],
- 'day': [
- 'الإثنين',
- 'الثلاثاء',
- 'الأربعاء',
- 'الخميس',
- 'الجمعه',
- 'السبت',
- 'الاحد'
- ],
+ 'day': ['الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعه', 'السبت', 'الاحد'],
'am': 'ص',
'pm': 'م'
},
@@ -679,20 +468,7 @@ final _i18nModel = >{
'cancel': 'İptal',
'done': 'Tamam',
'today': 'Bugün',
- 'monthShort': [
- 'Oca',
- 'Şub',
- 'Mar',
- 'Nis',
- 'May',
- 'Haz',
- 'Tem',
- 'Ağu',
- 'Eyl',
- 'Eki',
- 'Kas',
- 'Ara'
- ],
+ 'monthShort': ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'],
'monthLong': [
'Ocak',
'Şubat',
@@ -715,20 +491,7 @@ final _i18nModel = >{
'cancel': 'Ləğv et',
'done': 'Bitdi',
'today': 'Bugün',
- 'monthShort': [
- 'Yan',
- 'Fev',
- 'Mar',
- 'Apr',
- 'May',
- 'İyn',
- 'İyl',
- 'Avq',
- 'Sen',
- 'Okt',
- 'Noy',
- 'Dek'
- ],
+ 'monthShort': ['Yan', 'Fev', 'Mar', 'Apr', 'May', 'İyn', 'İyl', 'Avq', 'Sen', 'Okt', 'Noy', 'Dek'],
'monthLong': [
'Yanvar',
'Fevral',
@@ -752,34 +515,8 @@ final _i18nModel = >{
'cancel': 'キャンセル',
'done': '完了',
'today': '今日',
- 'monthShort': [
- '1月',
- '2月',
- '3月',
- '4月',
- '5月',
- '6月',
- '7月',
- '8月',
- '9月',
- '10月',
- '11月',
- '12月'
- ],
- 'monthLong': [
- '1月',
- '2月',
- '3月',
- '4月',
- '5月',
- '6月',
- '7月',
- '8月',
- '9月',
- '10月',
- '11月',
- '12月'
- ],
+ 'monthShort': ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
+ 'monthLong': ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
'day': ['月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日', '日曜日'],
'am': '午前',
'pm': '午後'
@@ -789,20 +526,7 @@ final _i18nModel = >{
'cancel': 'Abbrechen',
'done': 'OK',
'today': 'Heute',
- 'monthShort': [
- 'Jan',
- 'Feb',
- 'Mrz',
- 'Apr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Dez'
- ],
+ 'monthShort': ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
'monthLong': [
'Januar',
'Februar',
@@ -826,20 +550,7 @@ final _i18nModel = >{
'cancel': 'Annullér',
'done': 'OK',
'today': 'I dag',
- 'monthShort': [
- 'jan',
- 'feb',
- 'mar',
- 'apr',
- 'maj',
- 'juni',
- 'juli',
- 'aug',
- 'sept',
- 'okt',
- 'nov',
- 'dec'
- ],
+ 'monthShort': ['jan', 'feb', 'mar', 'apr', 'maj', 'juni', 'juli', 'aug', 'sept', 'okt', 'nov', 'dec'],
'monthLong': [
'januar',
'februar',
@@ -907,20 +618,7 @@ final _i18nModel = >{
'cancel': 'Hủy bỏ',
'done': 'Xong',
'today': 'Hôm nay',
- 'monthShort': [
- 'Thg1',
- 'Thg2',
- 'Thg3',
- 'Thg4',
- 'Thg5',
- 'Thg6',
- 'Thg7',
- 'Thg8',
- 'Thg9',
- 'Thg10',
- 'Thg11',
- 'Thg12'
- ],
+ 'monthShort': ['Thg1', 'Thg2', 'Thg3', 'Thg4', 'Thg5', 'Thg6', 'Thg7', 'Thg8', 'Thg9', 'Thg10', 'Thg11', 'Thg12'],
'monthLong': [
'Tháng 1',
'Tháng 2',
@@ -944,20 +642,7 @@ final _i18nModel = >{
'cancel': 'Չեղարկել',
'done': 'հաստատել',
'today': 'Այսօր',
- 'monthShort': [
- 'Հնվ',
- 'Փետ',
- 'Մար',
- 'Ապր',
- 'Մայ',
- 'Հուն',
- 'Հուլ',
- 'Օգոս',
- 'Սեպ',
- 'Հոկ',
- 'Նոյ',
- 'Դեկ'
- ],
+ 'monthShort': ['Հնվ', 'Փետ', 'Մար', 'Ապր', 'Մայ', 'Հուն', 'Հուլ', 'Օգոս', 'Սեպ', 'Հոկ', 'Նոյ', 'Դեկ'],
'monthLong': [
'Հունվար',
'Փետրվար',
@@ -980,20 +665,7 @@ final _i18nModel = >{
'cancel': 'Batal',
'done': 'Pilih',
'today': 'Hari Ini',
- 'monthShort': [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'Mei',
- 'Jun',
- 'Jul',
- 'Agu',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Des'
- ],
+ 'monthShort': ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des'],
'monthLong': [
'Januari',
'Februari',
@@ -1016,20 +688,7 @@ final _i18nModel = >{
'cancel': 'Отказ',
'done': 'Готово',
'today': 'Днес',
- 'monthShort': [
- 'Яну',
- 'Фев',
- 'Март',
- 'Апр',
- 'Май',
- 'Юни',
- 'Юли',
- 'Авг',
- 'Сен',
- 'Окт',
- 'Ное',
- 'Дек'
- ],
+ 'monthShort': ['Яну', 'Фев', 'Март', 'Апр', 'Май', 'Юни', 'Юли', 'Авг', 'Сен', 'Окт', 'Ное', 'Дек'],
'monthLong': [
'Януари',
'Февруари',
@@ -1053,20 +712,7 @@ final _i18nModel = >{
'cancel': 'Ezeztau',
'done': 'Onartu',
'today': 'Gaur',
- 'monthShort': [
- 'urt.',
- 'ots.',
- 'mar.',
- 'api.',
- 'mai.',
- 'eka.',
- 'uzt.',
- 'abu.',
- 'ira.',
- 'urr.',
- 'aza.',
- 'abe.'
- ],
+ 'monthShort': ['urt.', 'ots.', 'mar.', 'api.', 'mai.', 'eka.', 'uzt.', 'abu.', 'ira.', 'urr.', 'aza.', 'abe.'],
'monthLong': [
'urtarrila',
'otsaila',
@@ -1090,20 +736,7 @@ final _i18nModel = >{
'cancel': 'Cancel·la',
'done': 'Confirmar',
'today': 'Avui',
- 'monthShort': [
- 'Gen',
- 'Febr',
- 'Març',
- 'Abr',
- 'Maig',
- 'Juny',
- 'Jul',
- 'Ag',
- 'Set',
- 'Oct',
- 'Nov',
- 'Des'
- ],
+ 'monthShort': ['Gen', 'Febr', 'Març', 'Abr', 'Maig', 'Juny', 'Jul', 'Ag', 'Set', 'Oct', 'Nov', 'Des'],
'monthLong': [
'Gener',
'Febrer',
@@ -1127,20 +760,7 @@ final _i18nModel = >{
'cancel': 'ยกเลิก',
'done': 'ตกลง',
'today': 'วันนี้',
- 'monthShort': [
- 'ม.ค',
- 'ก.พ',
- 'มี.ค',
- 'เม.ย',
- 'พ.ค',
- 'มิ.ย',
- 'ก.ค',
- 'ส.ค',
- 'ก.ย',
- 'ต.ค',
- 'พ.ย',
- 'ธ.ค'
- ],
+ 'monthShort': ['ม.ค', 'ก.พ', 'มี.ค', 'เม.ย', 'พ.ค', 'มิ.ย', 'ก.ค', 'ส.ค', 'ก.ย', 'ต.ค', 'พ.ย', 'ธ.ค'],
'monthLong': [
'มกราคม',
'กุมภาพันธ์',
@@ -1164,20 +784,7 @@ final _i18nModel = >{
'cancel': 'Prekliči',
'done': 'V redu',
'today': 'Danes',
- 'monthShort': [
- 'jan',
- 'feb',
- 'mar',
- 'apr',
- 'maj',
- 'jun',
- 'jul',
- 'avg',
- 'sep',
- 'okt',
- 'nov',
- 'dec'
- ],
+ 'monthShort': ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'avg', 'sep', 'okt', 'nov', 'dec'],
'monthLong': [
'januar',
'februar',
@@ -1200,20 +807,7 @@ final _i18nModel = >{
'cancel': 'Avbryt',
'done': 'Ferdig',
'today': 'Idag',
- 'monthShort': [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Des'
- ],
+ 'monthShort': ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'],
'monthLong': [
'Januar',
'Februar',
@@ -1236,20 +830,7 @@ final _i18nModel = >{
'cancel': 'Anulo',
'done': 'Perfundo',
'today': 'Sot',
- 'monthShort': [
- 'Jan',
- 'Shk',
- 'Mar',
- 'Pri',
- 'Maj',
- 'Qer',
- 'Kor',
- 'Gus',
- 'Sht',
- 'Tet',
- 'Nen',
- 'Dhj'
- ],
+ 'monthShort': ['Jan', 'Shk', 'Mar', 'Pri', 'Maj', 'Qer', 'Kor', 'Gus', 'Sht', 'Tet', 'Nen', 'Dhj'],
'monthLong': [
'Janar',
'Shkurt',
@@ -1272,20 +853,7 @@ final _i18nModel = >{
'cancel': 'Avbryt',
'done': 'Klar',
'today': 'I dag',
- 'monthShort': [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'Maj',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Dec'
- ],
+ 'monthShort': ['Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'],
'monthLong': [
'Januari',
'Februari',
@@ -1307,12 +875,11 @@ final _i18nModel = >{
};
/// Get international object for [localeType]
-Map i18nObjInLocale(LocaleType localeType) =>
- _i18nModel[localeType] ?? _i18nModel[LocaleType.en];
+Map? i18nObjInLocale(LocaleType localeType) => _i18nModel[localeType] ?? _i18nModel[LocaleType.en];
/// Get international lookup for a [localeType], [key] and [index].
String i18nObjInLocaleLookup(LocaleType localeType, String key, int index) {
- final i18n = i18nObjInLocale(localeType);
- final i18nKey = i18n[key] as List;
+ final Map? i18n = i18nObjInLocale(localeType);
+ final List i18nKey = i18n![key]! as List;
return i18nKey[index];
}
diff --git a/pubspec.yaml b/pubspec.yaml
index f0555cce..8e4a3210 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@ version: 1.4.0
homepage: https://github.com/Realank/flutter_datetime_picker
environment:
- sdk: ">=2.0.0 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
@@ -13,6 +13,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
+ build_runner: ^1.10.1
+ pedantic: ^1.9.2
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec