Skip to content

Commit

Permalink
refactor: refactored code
Browse files Browse the repository at this point in the history
 * Add Null Safety Support

 * Removed unused imports
  • Loading branch information
shan-shaji committed Sep 9, 2021
1 parent 816687b commit c281f72
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 58 deletions.
40 changes: 20 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
25 changes: 12 additions & 13 deletions lib/src/select_day.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -84,11 +84,10 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
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 {
Expand All @@ -97,7 +96,7 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
}

// getter to handle fill color of buttons.
Color get _handleDaysFillColor {
Color? get _handleDaysFillColor {
if (widget.daysFillColor == null) {
return Colors.white;
} else {
Expand All @@ -106,7 +105,7 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
}

//getter to handle border color of days[buttons].
Color get _handleBorderColorOfDays {
Color? get _handleBorderColorOfDays {
if (widget.daysBorderColor == null) {
return Colors.white;
} else {
Expand All @@ -115,7 +114,7 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
}

// 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;
Expand All @@ -130,7 +129,7 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
}
}
}
//====================================================================================//


@override
Widget build(BuildContext context) {
Expand All @@ -154,7 +153,7 @@ class _SelectWeekDaysState extends State<SelectWeekDays> {
shape: CircleBorder(
side: widget.border
? BorderSide(
color: _handleBorderColorOfDays,
color: _handleBorderColorOfDays!,
width: 2.0,
)
: BorderSide.none,
Expand Down
40 changes: 20 additions & 20 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Loading

0 comments on commit c281f72

Please sign in to comment.