mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-24 01:08:09 +08:00

Instead we're going to move back to standard exceptions. Using a custom Result class has created far far more problems - The Stacktraces aren't always right - Sometimes one forgets to check the Result error - All other exception throwing code needing to be converted to Results - Non idiomatic Dart code I think it's better to just go back to exceptions. They have their problems, but overall, I think it's a better approach.
36 lines
878 B
Dart
36 lines
878 B
Dart
/*
|
|
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:gitjournal/settings/settings_sharedpref.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class AnalyticsConfig extends ChangeNotifier with SettingsSharedPref {
|
|
AnalyticsConfig(this.id, this.pref);
|
|
|
|
@override
|
|
final String id;
|
|
|
|
@override
|
|
final SharedPreferences pref;
|
|
|
|
var appVersion = "";
|
|
var enabled = true;
|
|
|
|
void load(SharedPreferences pref) {
|
|
appVersion = pref.getString("appVersion") ?? "";
|
|
|
|
enabled = getBool("collectUsageStatistics") ?? enabled;
|
|
}
|
|
|
|
Future<void> save() async {
|
|
var def = AnalyticsConfig(id, pref);
|
|
|
|
await setBool("collectUsageStatistics", enabled, def.enabled);
|
|
await pref.setString("appVersion", appVersion);
|
|
}
|
|
}
|