flutter linting

This commit is contained in:
unknown
2022-01-05 13:02:22 +01:00
parent 79f6ef4c50
commit 339dbea1ef
26 changed files with 226 additions and 143 deletions

View File

@@ -58,10 +58,11 @@ class Version {
// check for valid prerelease name
if (p[0] != "") {
if (prereleases.contains(p[0].toLowerCase().trim()))
if (prereleases.contains(p[0].toLowerCase().trim())) {
pre = p[0];
else
} else {
throw "invalid prerelease name: ${p[0]}";
}
}
// core
@@ -74,6 +75,7 @@ class Version {
return Version(x, y, z, prerelease: pre, prever: prev);
} catch (error) {
// ignore: avoid_print
print("WARNING: Failed to parse version ($o): $error");
return Version.zero;
}
@@ -126,4 +128,7 @@ class Version {
static const zero = Version(0, 0, 0);
static const List<String> prereleases = ["dev", "pre", "alpha", "beta", "rc"];
@override
int get hashCode => toString().hashCode;
}

View File

@@ -44,7 +44,7 @@ class SettingsProvider extends ChangeNotifier {
int _notificationPollInterval;
bool _developerMode;
VibrationStrength _vibrate;
bool _ABweeks;
bool _abWeeks;
bool _swapABweeks;
UpdateChannel _updateChannel;
Config _config;
@@ -64,7 +64,7 @@ class SettingsProvider extends ChangeNotifier {
required bool developerMode,
required int notificationPollInterval,
required VibrationStrength vibrate,
required bool ABweeks,
required bool abWeeks,
required bool swapABweeks,
required UpdateChannel updateChannel,
required Config config,
@@ -82,7 +82,7 @@ class SettingsProvider extends ChangeNotifier {
_developerMode = developerMode,
_notificationPollInterval = notificationPollInterval,
_vibrate = vibrate,
_ABweeks = ABweeks,
_abWeeks = abWeeks,
_swapABweeks = swapABweeks,
_updateChannel = updateChannel,
_config = config,
@@ -113,7 +113,7 @@ class SettingsProvider extends ChangeNotifier {
notificationPollInterval: map["notification_poll_interval"],
developerMode: map["developer_mode"] == 1 ? true : false,
vibrate: VibrationStrength.values[map["vibration_strength"]],
ABweeks: map["ab_weeks"] == 1 ? true : false,
abWeeks: map["ab_weeks"] == 1 ? true : false,
swapABweeks: map["swap_ab_weeks"] == 1 ? true : false,
updateChannel: UpdateChannel.values[map["update_channel"]],
config: Config.fromJson(jsonDecode(map["config"] ?? "{}")),
@@ -140,7 +140,7 @@ class SettingsProvider extends ChangeNotifier {
"grade_color5": _gradeColors[4].value,
"update_channel": _updateChannel.index,
"vibration_strength": _vibrate.index,
"ab_weeks": _ABweeks ? 1 : 0,
"ab_weeks": _abWeeks ? 1 : 0,
"swap_ab_weeks": _swapABweeks ? 1 : 0,
"notification_poll_interval": _notificationPollInterval,
"config": jsonEncode(config.json),
@@ -169,11 +169,11 @@ class SettingsProvider extends ChangeNotifier {
developerMode: false,
notificationPollInterval: 1,
vibrate: VibrationStrength.medium,
ABweeks: false,
abWeeks: false,
swapABweeks: false,
updateChannel: UpdateChannel.stable,
config: Config.fromJson({}),
xFilcId: Uuid().v4(),
xFilcId: const Uuid().v4(),
);
}
@@ -191,7 +191,7 @@ class SettingsProvider extends ChangeNotifier {
bool get developerMode => _developerMode;
int get notificationPollInterval => _notificationPollInterval;
VibrationStrength get vibrate => _vibrate;
bool get ABweeks => _ABweeks;
bool get abWeeks => _abWeeks;
bool get swapABweeks => _swapABweeks;
UpdateChannel get updateChannel => _updateChannel;
PackageInfo? get packageInfo => _packageInfo;
@@ -214,7 +214,7 @@ class SettingsProvider extends ChangeNotifier {
bool? developerMode,
int? notificationPollInterval,
VibrationStrength? vibrate,
bool? ABweeks,
bool? abWeeks,
bool? swapABweeks,
UpdateChannel? updateChannel,
Config? config,
@@ -231,16 +231,17 @@ class SettingsProvider extends ChangeNotifier {
if (notificationsEnabled != null && notificationsEnabled != _notificationsEnabled) _notificationsEnabled = notificationsEnabled;
if (notificationsBitfield != null && notificationsBitfield != _notificationsBitfield) _notificationsBitfield = notificationsBitfield;
if (developerMode != null && developerMode != _developerMode) _developerMode = developerMode;
if (notificationPollInterval != null && notificationPollInterval != _notificationPollInterval)
if (notificationPollInterval != null && notificationPollInterval != _notificationPollInterval) {
_notificationPollInterval = notificationPollInterval;
}
if (vibrate != null && vibrate != _vibrate) _vibrate = vibrate;
if (ABweeks != null && ABweeks != _ABweeks) _ABweeks = ABweeks;
if (abWeeks != null && abWeeks != _abWeeks) _abWeeks = abWeeks;
if (swapABweeks != null && swapABweeks != _swapABweeks) _swapABweeks = swapABweeks;
if (updateChannel != null && updateChannel != _updateChannel) _updateChannel = updateChannel;
if (config != null && config != _config) _config = config;
if (xFilcId != null && xFilcId != _xFilcId) _xFilcId = xFilcId;
if (database == null) database = Provider.of<DatabaseProvider>(context, listen: false);
database ??= Provider.of<DatabaseProvider>(context, listen: false);
await database.store.storeSettings(this);
notifyListeners();
}

View File

@@ -26,7 +26,7 @@ class User {
if (id != null) {
this.id = id;
} else {
this.id = Uuid().v4();
this.id = const Uuid().v4();
}
}
@@ -67,7 +67,7 @@ class User {
"password": password,
"institute_code": instituteCode,
"grant_type": "password",
"client_id": KretaAPI.CLIENT_ID,
"client_id": KretaAPI.clientId,
};
}
}