Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Migrate to null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
eightgran committed Mar 30, 2021
1 parent cebfe3e commit 7d74840
Show file tree
Hide file tree
Showing 76 changed files with 586 additions and 594 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2

* Migrate to null safety

## 1.0.1

* Added several new widgets and screens
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020 Michael Grigorenko. All rights reserved.
Copyright 2020-2021 LitLifeSoftware. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand All @@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Michael Grigorenko nor the names of its
* Neither the name of LitLifeSoftware nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

Expand Down
74 changes: 41 additions & 33 deletions example/lib/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ import 'package:flutter/material.dart';
import 'package:lit_ui_kit/lit_ui_kit.dart';

class LitUIKitHomescreen extends StatefulWidget {
LitUIKitHomescreen({Key key}) : super(key: key);
LitUIKitHomescreen({Key? key}) : super(key: key);

@override
_LitUIKitHomescreenState createState() => _LitUIKitHomescreenState();
}

class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
SettingsPanelController settingsPanelController;
LitSnackbarController customSnackBarController;
LitNotificationController _notificationController;
bool darkMode;
DateTime dayOfBirth;
SettingsPanelController? settingsPanelController;
LitSnackbarController? customSnackBarController;
LitNotificationController? _notificationController;
bool? darkMode;
DateTime? dayOfBirth;

void onSubmitDayOfBirth(DateTime date) {
void onSubmitDayOfBirth(DateTime? date) {
Navigator.pop(context);
setState(() {
dayOfBirth = date;
});
}

void showSnackbar() {
customSnackBarController.showSnackBar();
customSnackBarController!.showSnackBar();
}

Color get buttonTextColor {
return darkMode ? Colors.white : LitColors.lightGrey;
return darkMode! ? Colors.white : LitColors.lightGrey;
}

Color get buttonBorderColor {
return darkMode ? Colors.white : LitColors.lightGrey;
return darkMode! ? Colors.white : LitColors.lightGrey;
}

void _addNotification() {
setState(() {
_notificationController.add(
_notificationController!.add(
LitNotificationData(
description: "${DateTime.now().toIso8601String()}",
icon: LitIcons.bolt,
Expand All @@ -59,32 +59,32 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
@override
Widget build(BuildContext context) {
return LitNotificationContainer(
controller: _notificationController,
controller: _notificationController!,
child: LitScaffold(
backgroundColor: darkMode ? LitColors.darkBlue : Colors.white,
backgroundColor: darkMode! ? LitColors.darkBlue : Colors.white,
appBar: LitAppBar(
title: "LitUIKit Example",
backgroundColor: darkMode ? LitColors.darkBlue : LitColors.lightGrey,
backgroundColor: darkMode! ? LitColors.darkBlue : LitColors.lightGrey,
textStyle: LitTextStyles.sansSerif
.copyWith(color: darkMode ? Colors.white : LitColors.mediumGrey),
.copyWith(color: darkMode! ? Colors.white : LitColors.mediumGrey),
),
snackBar: IconSnackbar(
litSnackBarController: customSnackBarController,
text: "Snack Bar!",
iconData: LitIcons.info),
settingsPanel: SettingsPanel(
controller: settingsPanelController,
controller: settingsPanelController!,
title: "Settings",
darkMode: darkMode,
darkMode: darkMode!,
settingsTiles: [
SettingsTile(
onValueToggled: (toggledValue) {
setState(() {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -94,8 +94,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -105,8 +105,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -116,8 +116,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -127,8 +127,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -138,8 +138,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -149,8 +149,8 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
darkMode = toggledValue;
});
},
darkMode: darkMode,
enabled: darkMode,
darkMode: darkMode!,
enabled: darkMode!,
optionName: "Dark mode",
iconData: LitIcons.moon_with_stars_solid,
),
Expand All @@ -164,7 +164,7 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
),
backgroundColor: LitColors.mediumGrey,
onPressed: () => {
settingsPanelController.showSettingsPanel(),
settingsPanelController!.showSettingsPanel(),
}),
body: ScrollableColumn(
mainAxisSize: MainAxisSize.max,
Expand All @@ -184,7 +184,7 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
? Padding(
padding: const EdgeInsets.only(top: 32.0),
child: ClippedText(
"You were born in ${dayOfBirth.year}",
"You were born in ${dayOfBirth!.year}",
style: LitTextStyles.sansSerif.copyWith(
color: buttonTextColor,
),
Expand Down Expand Up @@ -273,6 +273,14 @@ class _LitUIKitHomescreenState extends State<LitUIKitHomescreen> {
CupertinoPageRoute(
builder: (context) {
return LitOnboardingScreen(
artwork: Padding(
padding:
const EdgeInsets.symmetric(vertical: 64.0),
child: Text(
"Onboarding Screen",
style: LitTextStyles.sansSerifTitle,
),
),
onStartCallback: () =>
Navigator.of(context).pop(),
instructionCards: [
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "1.0.2"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -143,5 +143,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0-259.9.beta <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

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

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion lib/lit_ui_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8


/// A collection of Flutter widgets.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/lit_notification_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LitNotificationData {
///
/// * [icon] is the [IconData] used to assemble the icon next to the text.
const LitNotificationData({
@required this.description,
@required this.icon,
required this.description,
required this.icon,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@ import 'package:intl/intl.dart';
import 'package:lit_ui_kit/lit_ui_kit.dart';
import 'package:lit_ui_kit/src/util/calendar_controller.dart';
import 'package:lit_ui_kit/src/widgets/containers/on_value_changed_animated_container.dart';
import 'age_confirmation_controller.dart';

/// A [Widget] to display the current calendar date on the [AgeConfirmationScreen].
class AgeConfirmationCalendarDateIndicators extends StatefulWidget {
final AnimationController parentAnimation;
final AnimationController? parentAnimation;

final CalendarController calendarController;
final bool shouldAnimateMonthTransition;
final bool shouldAnimateYearTransition;
final bool? shouldAnimateMonthTransition;
final bool? shouldAnimateYearTransition;

final void Function(bool) toggleShouldAnimateMonthTransitionCallback;
final void Function(bool) setShouldAnimateYearTransitionCallback;

/// Creates a [AgeConfirmationCalendarDateIndicators].
const AgeConfirmationCalendarDateIndicators({
Key key,
@required this.parentAnimation,
@required this.calendarController,
@required this.shouldAnimateMonthTransition,
@required this.shouldAnimateYearTransition,
@required this.toggleShouldAnimateMonthTransitionCallback,
@required this.setShouldAnimateYearTransitionCallback,
Key? key,
required this.parentAnimation,
required this.calendarController,
required this.shouldAnimateMonthTransition,
required this.shouldAnimateYearTransition,
required this.toggleShouldAnimateMonthTransitionCallback,
required this.setShouldAnimateYearTransitionCallback,
}) : super(key: key);

@override
Expand Down Expand Up @@ -65,7 +64,7 @@ class _AgeConfirmationCalendarDateIndicatorsState
horizontal: 16.0,
),
child: ClippedText(
"${DateFormat.MMMM('${Localizations.localeOf(context).languageCode}').format(widget.calendarController.templateDate)}",
"${DateFormat.MMMM('${Localizations.localeOf(context).languageCode}').format(widget.calendarController.templateDate!)}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
Expand All @@ -87,7 +86,7 @@ class _AgeConfirmationCalendarDateIndicatorsState
),
borderRadius: BorderRadius.circular(20.0),
),
duration: widget.parentAnimation.duration,
duration: widget.parentAnimation!.duration,
toggleShouldAnimate:
widget.toggleShouldAnimateMonthTransitionCallback)
// AnimatedBuilder(
Expand Down Expand Up @@ -149,7 +148,7 @@ class _AgeConfirmationCalendarDateIndicatorsState
horizontal: 16.0,
),
child: ClippedText(
"${DateFormat('yyyy').format(widget.calendarController.templateDate)}",
"${DateFormat('yyyy').format(widget.calendarController.templateDate!)}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
Expand All @@ -171,7 +170,7 @@ class _AgeConfirmationCalendarDateIndicatorsState
),
borderRadius: BorderRadius.circular(20.0),
),
duration: widget.parentAnimation.duration,
duration: widget.parentAnimation!.duration,
toggleShouldAnimate:
widget.setShouldAnimateYearTransitionCallback),

Expand Down
Loading

0 comments on commit 7d74840

Please sign in to comment.