From c281f72de6a767b1fd6fac517ec9cc5f256fb806 Mon Sep 17 00:00:00 2001 From: shan-shaji Date: Thu, 9 Sep 2021 14:40:21 +0530 Subject: [PATCH] refactor: refactored code * Add Null Safety Support * Removed unused imports --- example/pubspec.lock | 40 +++++++++++++++++++-------------------- lib/src/select_day.dart | 25 ++++++++++++------------ pubspec.lock | 40 +++++++++++++++++++-------------------- pubspec.yaml | 2 +- test/day_picker_test.dart | 4 ---- 5 files changed, 53 insertions(+), 58 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 6b82549..065e0f3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -63,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -80,21 +80,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -106,56 +106,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.17.0" diff --git a/lib/src/select_day.dart b/lib/src/select_day.dart index 0e12ee5..5997127 100644 --- a/lib/src/select_day.dart +++ b/lib/src/select_day.dart @@ -6,7 +6,7 @@ class SelectWeekDays extends StatefulWidget { final Function onSelect; // [backgroundColor] - property to change the color of the container. - final Color backgroundColor, + final Color? backgroundColor, // [daysFillColor] - property to change the button color of days when the button is pressed. daysFillColor, // [daysBorderColor] - property to change the bordercolor of the rounded buttons. @@ -20,11 +20,11 @@ class SelectWeekDays extends StatefulWidget { final bool border; // [boxDecoration] to handle the decoration of the container. - final BoxDecoration boxDecoration; + final BoxDecoration? boxDecoration; // [padding] property to handle the padding between the container and buttons by default it is 8.0 final double padding; SelectWeekDays({ - @required this.onSelect, + required this.onSelect, this.backgroundColor, this.daysFillColor, this.daysBorderColor, @@ -33,8 +33,8 @@ class SelectWeekDays extends StatefulWidget { this.border = true, this.boxDecoration, this.padding = 8.0, - Key key, - }) : assert(onSelect != null), + Key? key, + }) : super(key: key); @override @@ -84,11 +84,10 @@ class _SelectWeekDaysState extends State { widget.onSelect(selectedDays.toList()); } -//====================================================================================// -// Handles color of widgets. + // Handles color of widgets. // getter to handle background color of container. - Color get _handleBackgroundColor { + Color? get _handleBackgroundColor { if (widget.backgroundColor == null) { return Theme.of(context).accentColor; } else { @@ -97,7 +96,7 @@ class _SelectWeekDaysState extends State { } // getter to handle fill color of buttons. - Color get _handleDaysFillColor { + Color? get _handleDaysFillColor { if (widget.daysFillColor == null) { return Colors.white; } else { @@ -106,7 +105,7 @@ class _SelectWeekDaysState extends State { } //getter to handle border color of days[buttons]. - Color get _handleBorderColorOfDays { + Color? get _handleBorderColorOfDays { if (widget.daysBorderColor == null) { return Colors.white; } else { @@ -115,7 +114,7 @@ class _SelectWeekDaysState extends State { } // Handler to change the text color when the button is pressed and not pressed. - Color _handleTextColor(bool onSelect) { + Color? _handleTextColor(bool onSelect) { if (onSelect == true) { if (widget.selectedDayTextColor == null) { return Colors.black; @@ -130,7 +129,7 @@ class _SelectWeekDaysState extends State { } } } -//====================================================================================// + @override Widget build(BuildContext context) { @@ -154,7 +153,7 @@ class _SelectWeekDaysState extends State { shape: CircleBorder( side: widget.border ? BorderSide( - color: _handleBorderColorOfDays, + color: _handleBorderColorOfDays!, width: 2.0, ) : BorderSide.none, diff --git a/pubspec.lock b/pubspec.lock index 59449b7..010beab 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,56 +92,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index 21a8730..ff7f873 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ author: Shan Shaji homepage: https://github.com/shan-shaji/day_picker environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=1.17.0 <2.0.0" dependencies: diff --git a/test/day_picker_test.dart b/test/day_picker_test.dart index 81170cf..ab73b3a 100644 --- a/test/day_picker_test.dart +++ b/test/day_picker_test.dart @@ -1,5 +1 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - - void main() {}