updated project style guidelines

This commit is contained in:
2024-04-03 19:18:17 +02:00
parent 27618f4404
commit 4c7f53e309
185 changed files with 505 additions and 873 deletions
analysis_options.yaml
lib
api
apiError.dartapiParams.dartapiRequest.dartapiResponse.dart
holidays
marianumcloud
mhsl
requestCache.dart
webuntis
app.dart
extensions
main.dart
model
notification
storage
theming
view
widget

@ -1,30 +1,20 @@
import 'package:flutter/material.dart';
extension IsSameDay on DateTime {
bool isSameDay(DateTime other) {
return year == other.year && month == other.month && day == other.day;
}
bool isSameDay(DateTime other) => year == other.year && month == other.month && day == other.day;
DateTime nextWeekday(int day) {
return add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
}
DateTime nextWeekday(int day) => add(Duration(days: (day - weekday) % DateTime.daysPerWeek));
DateTime withTime(TimeOfDay time) {
return copyWith(hour: time.hour, minute: time.minute);
}
DateTime withTime(TimeOfDay time) => copyWith(hour: time.hour, minute: time.minute);
TimeOfDay toTimeOfDay() {
return TimeOfDay(hour: hour, minute: minute);
}
TimeOfDay toTimeOfDay() => TimeOfDay(hour: hour, minute: minute);
bool isSameDateTime(DateTime other) {
bool isSameDay = this.isSameDay(other);
bool isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
var isSameDay = this.isSameDay(other);
var isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
return isSameDay && isSameTimeOfDay;
}
bool isSameOrAfter(DateTime other) {
return isSameDateTime(other) || isAfter(other);
}
}
bool isSameOrAfter(DateTime other) => isSameDateTime(other) || isAfter(other);
}

@ -1,5 +1,3 @@
extension RenderNotNullExt<T> on T? {
R? wrapNullable<R>(R Function(T data) defaultValueCallback) {
return this != null ? defaultValueCallback(this as T) : null;
}
}
R? wrapNullable<R>(R Function(T data) defaultValueCallback) => this != null ? defaultValueCallback(this as T) : null;
}

@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
extension TextExt on Text {
Size get size {
final TextPainter textPainter = TextPainter(
final textPainter = TextPainter(
text: TextSpan(text: data, style: style),
maxLines: 1,
textDirection: TextDirection.ltr
)..layout(minWidth: 0, maxWidth: double.infinity);
return textPainter.size;
}
}
}

@ -1,15 +1,9 @@
import 'package:flutter/material.dart';
extension TimeOfDayExt on TimeOfDay {
bool isBefore(TimeOfDay other) {
return hour < other.hour && minute < other.minute;
}
bool isBefore(TimeOfDay other) => hour < other.hour && minute < other.minute;
bool isAfter(TimeOfDay other) {
return hour > other.hour && minute > other.minute;
}
bool isAfter(TimeOfDay other) => hour > other.hour && minute > other.minute;
TimeOfDay add({int hours = 0, int minutes = 0}) {
return replacing(hour: hour + hours, minute: minute + minutes);
}
}
TimeOfDay add({int hours = 0, int minutes = 0}) => replacing(hour: hour + hours, minute: minute + minutes);
}