Updated Flutter SDK for Null-Safety

Ported Progress Detail Screen to PlatformScaffold

Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
Andreas Fahrecker
2021-03-18 18:34:29 +01:00
parent b1a90b1e05
commit 08db53db20
34 changed files with 245 additions and 138 deletions

View File

@ -7,22 +7,16 @@ class AppSettings {
final Color leftColor;
final Duration duration;
AppSettings({
this.doneColor,
this.leftColor,
this.duration,
const AppSettings({
required this.doneColor,
required this.leftColor,
required this.duration,
});
factory AppSettings.defaults() => AppSettings(
doneColor: Colors.green,
leftColor: Colors.red,
duration: Duration(days: 365),
);
AppSettings copyWith({
Color doneColor,
Color leftColor,
Duration duration,
Color? doneColor,
Color? leftColor,
Duration? duration,
}) =>
AppSettings(
doneColor: doneColor ?? this.doneColor,

View File

@ -10,7 +10,7 @@ class TimeProgress {
final DateTime startTime;
final DateTime endTime;
TimeProgress(this.name, this.startTime, this.endTime, {String id})
TimeProgress(this.name, this.startTime, this.endTime, {String? id})
: id = id ?? Uuid().generateV4();
factory TimeProgress.initialDefault() {
@ -23,7 +23,7 @@ class TimeProgress {
TimeProgress("", DateTime.now(), DateTime.now().add(duration));
TimeProgress copyWith(
{String id, String name, DateTime startTime, DateTime endTime}) =>
{String? id, String? name, DateTime? startTime, DateTime? endTime}) =>
TimeProgress(
name ?? this.name,
startTime ?? this.startTime,
@ -87,16 +87,19 @@ class TimeProgress {
return TimeProgressEntity(id, name, startTime, endTime);
}
static TimeProgress fromEntity(TimeProgressEntity entity) =>
TimeProgress(entity.name, entity.startTime, entity.endTime,
id: entity.id ?? Uuid().generateV4());
static TimeProgress fromEntity(TimeProgressEntity entity) => TimeProgress(
entity.name,
entity.startTime,
entity.endTime,
id: entity.id,
);
static bool isValid(TimeProgress tp) =>
TimeProgress.isNameValid(tp.name) &&
TimeProgress.areTimesValid(tp.startTime, tp.endTime);
static bool isNameValid(String name) =>
name != null && name != "" && name.length > 2 && name.length < 21;
name != "" && name.length > 2 && name.length < 21;
static bool areTimesValid(DateTime startTime, DateTime endTime) =>
startTime.isBefore(endTime);