Skip to content
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

Add null safety support #26

Merged
merged 8 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ doc/
pubspec.lock

.idea
.vscode/
example/ios/Flutter/flutter_export_environment.sh
example/.flutter-plugins-dependencies
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.5/","dependencies":[]},{"name":"shared_preferences","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.12/","dependencies":[]}],"android":[{"name":"file_picker","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.5/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.11/","dependencies":[]},{"name":"shared_preferences","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.12/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+2/","dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.0.4+1/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-0.0.1+1/","dependencies":["path_provider_windows"]}],"web":[{"name":"file_picker","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.5/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/jeff/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2021-02-08 10:54:47.264142","version":"1.25.0-8.2.pre"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-3.0.0\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-2.0.3\\\\","dependencies":[]}],"android":[{"name":"file_picker","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-3.0.0\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.0\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-2.0.3\\\\","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-2.0.0\\\\","dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_windows-2.0.0\\\\","dependencies":["path_provider_windows"]}],"web":[{"name":"file_picker","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-3.0.0\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\Users\\\\ahmed\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2021-03-04 22:32:43.502182","version":"2.0.0"}
15 changes: 8 additions & 7 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/jeff/Development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/jeff/OneDrive/Projects/Code/Flutter Packages/flutter_material_pickers/example"
export "FLUTTER_TARGET=/Users/jeff/OneDrive/Projects/Code/Flutter Packages/flutter_material_pickers/example/lib/main.dart"
export "FLUTTER_ROOT=C:\Users\ahmed\AppData\Local\Android\flutter"
export "FLUTTER_APPLICATION_PATH=D:\Development\projects\forks\flutter_material_pickers\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\Users\ahmed\AppData\Local\Android\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=/Users/jeff/OneDrive/Projects/Code/Flutter Packages/flutter_material_pickers/example/.dart_tool/package_config.json"
export "PACKAGE_CONFIG=.packages"
51 changes: 25 additions & 26 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:dynamic_theme/dynamic_theme.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_material_pickers/flutter_material_pickers.dart';
import 'package:intl/intl.dart';

Expand All @@ -11,10 +10,11 @@ void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DynamicTheme(
defaultBrightness: Brightness.light,
data: _buildTheme,
themedWidgetBuilder: (context, theme) {
return AdaptiveTheme(
initial: AdaptiveThemeMode.light,
light: _buildTheme(Brightness.light),
dark: _buildTheme(Brightness.dark),
builder: (context, theme) {
return MaterialApp(
title: 'Material Picker Examples',
theme: theme,
Expand All @@ -40,15 +40,15 @@ ThemeData _buildTheme(Brightness brightness) {
dialogBackgroundColor:
Colors.green[100], // background color of the entire dialog
primaryTextTheme: theme.primaryTextTheme.copyWith(
headline6: theme.primaryTextTheme.headline6.copyWith(
headline6: theme.primaryTextTheme.headline6?.copyWith(
color: Colors.lightGreen[50], // text color of the header area
),
),
textTheme: theme.textTheme.copyWith(
bodyText2: theme.textTheme.bodyText2.copyWith(
bodyText2: theme.textTheme.bodyText2?.copyWith(
color: Colors.green[700], // text color of dialog text
),
button: theme.textTheme.button.copyWith(
button: theme.textTheme.button?.copyWith(
color: Colors.green[700], // text color of the action bar buttons
),
),
Expand Down Expand Up @@ -79,10 +79,7 @@ class _TestPageState extends State<TestPage> {
icon: Theme.of(context).brightness == Brightness.dark
? Icon(Icons.brightness_7)
: Icon(Icons.brightness_4),
onPressed: () => DynamicTheme.of(context).setBrightness(
Theme.of(context).brightness == Brightness.dark
? Brightness.light
: Brightness.dark),
onPressed: () => AdaptiveTheme.of(context).toggleThemeMode(),
)
],
bottom: TabBar(
Expand Down Expand Up @@ -151,7 +148,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Empty Dialog"),
onPressed: () => showMaterialResponsiveDialog(
context: context,
Expand Down Expand Up @@ -205,7 +202,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Scroll Picker"),
onPressed: () => showMaterialScrollPicker(
context: context,
Expand Down Expand Up @@ -235,7 +232,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Number Picker"),
onPressed: () => showMaterialNumberPicker(
context: context,
Expand Down Expand Up @@ -265,7 +262,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Checkbox Picker"),
onPressed: () => showMaterialCheckboxPicker(
context: context,
Expand All @@ -292,7 +289,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Radio Picker"),
onPressed: () => showMaterialRadioPicker(
context: context,
Expand All @@ -319,7 +316,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Selection Picker"),
onPressed: () => showMaterialSelectionPicker(
context: context,
Expand All @@ -346,7 +343,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Time Picker"),
onPressed: () => showMaterialTimePicker(
context: context,
Expand All @@ -370,9 +367,11 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Date Picker"),
onPressed: () => showMaterialDatePicker(
firstDate: DateTime(1990, 1, 1),
lastDate: DateTime(2050, 12, 31),
context: context,
selectedDate: model.date,
onChanged: (value) => setState(() => model.date = value),
Expand All @@ -394,7 +393,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Color Picker"),
onPressed: () => showMaterialColorPicker(
context: context,
Expand All @@ -420,7 +419,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Palette Picker"),
onPressed: () => showMaterialPalettePicker(
context: context,
Expand All @@ -446,7 +445,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("Swatch Picker"),
onPressed: () => showMaterialSwatchPicker(
context: context,
Expand All @@ -472,7 +471,7 @@ class _TestPageState extends State<TestPage> {
children: <Widget>[
Container(
width: 150.0,
child: RaisedButton(
child: ElevatedButton(
child: Text("File Picker"),
onPressed: () => showMaterialFilePicker(
context: context,
Expand All @@ -483,7 +482,7 @@ class _TestPageState extends State<TestPage> {
),
Expanded(
child: Text(
"${model.file.bytes.lengthInBytes} bytes",
"${model.file.bytes?.lengthInBytes} bytes",
textAlign: TextAlign.right,
),
),
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0+1
publish_to: none

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
flutter:
Expand All @@ -13,8 +13,8 @@ dependencies:
sdk: flutter
flutter_material_pickers:
path: ../
dynamic_theme: ^1.0.0
intl: ^0.17.0-nullsafety.2
adaptive_theme: ^2.0.0-nullsafety.1
intl: ^0.17.0

flutter:
uses-material-design: true
Expand Down
26 changes: 12 additions & 14 deletions lib/dialogs/checkbox_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class CheckboxPickerDialog extends StatefulWidget
implements ICommonDialogProperties {
CheckboxPickerDialog({
this.title,
this.items,
this.initialItems,
required this.items,
required this.initialItems,
this.headerColor,
this.headerTextColor,
this.backgroundColor,
Expand All @@ -29,23 +29,23 @@ class CheckboxPickerDialog extends StatefulWidget
final List<String> items;
final List<String> initialItems;
@override
final String title;
final String? title;
@override
final Color headerColor;
final Color? headerColor;
@override
final Color headerTextColor;
final Color? headerTextColor;
@override
final Color backgroundColor;
final Color? backgroundColor;
@override
final Color buttonTextColor;
final Color? buttonTextColor;
@override
final double maxLongSide;
final double? maxLongSide;
@override
final double maxShortSide;
final double? maxShortSide;
@override
final String confirmText;
final String? confirmText;
@override
final String cancelText;
final String? cancelText;

@override
State<CheckboxPickerDialog> createState() =>
Expand All @@ -58,12 +58,10 @@ class _CheckboxPickerDialogState extends State<CheckboxPickerDialog> {
selectedItems = List<String>.from(initialItems);
}

List<String> selectedItems;
late List<String> selectedItems;

@override
Widget build(BuildContext context) {
assert(context != null);

return ResponsiveDialog(
context: context,
title: widget.title,
Expand Down
28 changes: 13 additions & 15 deletions lib/dialogs/radio_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class RadioPickerDialog extends StatefulWidget
implements ICommonDialogProperties {
RadioPickerDialog({
this.title,
this.items,
this.initialItem,
required this.items,
required this.initialItem,
this.headerColor,
this.headerTextColor,
this.backgroundColor,
Expand All @@ -29,23 +29,23 @@ class RadioPickerDialog extends StatefulWidget
final List<String> items;
final String initialItem;
@override
final String title;
final String? title;
@override
final Color headerColor;
final Color? headerColor;
@override
final Color headerTextColor;
final Color? headerTextColor;
@override
final Color backgroundColor;
final Color? backgroundColor;
@override
final Color buttonTextColor;
final Color? buttonTextColor;
@override
final double maxLongSide;
final double? maxLongSide;
@override
final double maxShortSide;
final double? maxShortSide;
@override
final String confirmText;
final String? confirmText;
@override
final String cancelText;
final String? cancelText;

@override
State<RadioPickerDialog> createState() =>
Expand All @@ -55,12 +55,10 @@ class RadioPickerDialog extends StatefulWidget
class _RadioPickerDialogState extends State<RadioPickerDialog> {
_RadioPickerDialogState(this.selectedItem);

String selectedItem;
String? selectedItem;

@override
Widget build(BuildContext context) {
assert(context != null);

return ResponsiveDialog(
context: context,
title: widget.title,
Expand All @@ -74,7 +72,7 @@ class _RadioPickerDialogState extends State<RadioPickerDialog> {
cancelText: widget.cancelText,
child: RadioPicker(
items: widget.items,
initialItem: selectedItem,
initialItem: selectedItem!,
onChanged: (value) => setState(() => selectedItem = value),
),
okPressed: () => Navigator.of(context).pop(selectedItem),
Expand Down