mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Fix all dart analyze warnings in the Flutter frontend
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
cb2b3c6af7
commit
f34dfe8386
@@ -9,7 +9,7 @@ class NotificationList extends StatefulWidget {
|
||||
const NotificationList({super.key});
|
||||
|
||||
@override
|
||||
_NotificationListState createState() => _NotificationListState();
|
||||
State<NotificationList> createState() => _NotificationListState();
|
||||
}
|
||||
|
||||
class _NotificationListState extends State<NotificationList> {
|
||||
@@ -61,6 +61,7 @@ class _NotificationListState extends State<NotificationList> {
|
||||
return false;
|
||||
}
|
||||
await BackendAPI.instance.markNotificationAsRead(item.id);
|
||||
if (!context.mounted) return false;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Event marked as read'),
|
||||
@@ -95,6 +96,7 @@ class _NotificationListState extends State<NotificationList> {
|
||||
return false;
|
||||
}
|
||||
await BackendAPI.instance.markNotificationAsNew(item.id);
|
||||
if (!context.mounted) return false;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Event marked as unread'),
|
||||
|
||||
@@ -12,7 +12,7 @@ class Settings extends StatefulWidget {
|
||||
const Settings({super.key});
|
||||
|
||||
@override
|
||||
_SettingsState createState() => _SettingsState();
|
||||
State<Settings> createState() => _SettingsState();
|
||||
}
|
||||
|
||||
class _SettingsState extends State<Settings> {
|
||||
@@ -125,7 +125,7 @@ class _SettingsState extends State<Settings> {
|
||||
SizedBox(height: 16),
|
||||
// Theme selector
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedTheme,
|
||||
initialValue: _selectedTheme,
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
labelText: 'Theme',
|
||||
@@ -162,10 +162,12 @@ class _SettingsState extends State<Settings> {
|
||||
_apiKeyController.text,
|
||||
);
|
||||
|
||||
if (!context.mounted) return;
|
||||
setState(() {
|
||||
_testOk = testResult == null;
|
||||
if (testResult == null)
|
||||
if (testResult == null) {
|
||||
_connectionModified = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (testResult == null) {
|
||||
|
||||
@@ -15,10 +15,12 @@ class FriendlyDateFormatter {
|
||||
);
|
||||
|
||||
if (timeSince.inMinutes < 60) return '${timeSince.inMinutes} minutes ago';
|
||||
if (dateTimeWithoutTime == today)
|
||||
if (dateTimeWithoutTime == today) {
|
||||
return 'Today at ${DateFormat.Hm().format(dateTime)}';
|
||||
if (dateTimeWithoutTime == yesterday)
|
||||
}
|
||||
if (dateTimeWithoutTime == yesterday) {
|
||||
return 'Yesterday at ${DateFormat.Hm().format(dateTime)}';
|
||||
}
|
||||
|
||||
return DateFormat.yMMMMd().add_Hm().format(dateTime);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:encrypter/encrypter/xor.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:frontend/utils/pref_utils.dart';
|
||||
import '../model/notification.dart';
|
||||
|
||||
@@ -16,8 +17,8 @@ class BackendAPI {
|
||||
PrefUtil.getValue("base_url", "http://localhost:3000/api") as String;
|
||||
_apiKey = XOR().xorDecode(PrefUtil.getValue("api_key", "") as String);
|
||||
|
||||
print('Base URL: $_baseUrl');
|
||||
print('API KEY $_apiKey');
|
||||
debugPrint('Base URL: $_baseUrl');
|
||||
debugPrint('API KEY: $_apiKey');
|
||||
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
@@ -32,7 +33,7 @@ class BackendAPI {
|
||||
|
||||
// Returns null if the test was successful, and a String with a message about the issue if not
|
||||
static Future<String?> test(String baseUrl, String apiKey) async {
|
||||
print('About to test API with baseUrl=$baseUrl and apiKey=$apiKey');
|
||||
debugPrint('About to test API with baseUrl=$baseUrl and apiKey=$apiKey');
|
||||
Dio dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseUrl,
|
||||
@@ -67,22 +68,22 @@ class BackendAPI {
|
||||
late Dio _dio;
|
||||
|
||||
Future<void> markNotificationAsRead(int id) async {
|
||||
print('About to call /notifications/$id');
|
||||
debugPrint('About to call /notifications/$id');
|
||||
await _dio.get('/notifications/$id');
|
||||
}
|
||||
|
||||
Future<void> markNotificationAsNew(int id) async {
|
||||
print('About to call /notifications/$id/mark_as_new');
|
||||
debugPrint('About to call /notifications/$id/mark_as_new');
|
||||
await _dio.post('/notifications/$id/mark_as_new');
|
||||
}
|
||||
|
||||
Future<void> markAllNotificationsAsRead() async {
|
||||
print('About to call /notifications/mark_all_as_old');
|
||||
debugPrint('About to call /notifications/mark_all_as_old');
|
||||
await _dio.post('/notifications/mark_all_as_old');
|
||||
}
|
||||
|
||||
Future<List<Notification>> listNotifications(bool? isNew, int offset) async {
|
||||
print('About to call /notifications');
|
||||
debugPrint('About to call /notifications');
|
||||
|
||||
Response response;
|
||||
response = await _dio.get(
|
||||
@@ -94,16 +95,16 @@ class BackendAPI {
|
||||
},
|
||||
);
|
||||
|
||||
print('Received: ' + response.data.toString());
|
||||
debugPrint('Received: ${response.data}');
|
||||
|
||||
List<dynamic> list = response.data;
|
||||
print('List contains ' + list.length.toString() + ' items');
|
||||
debugPrint('List contains ${list.length} items');
|
||||
|
||||
List<Notification> events = List<Notification>.from(
|
||||
list.map((item) => Notification.fromJson(item)),
|
||||
);
|
||||
|
||||
print('Parsed ' + events.length.toString() + ' events');
|
||||
debugPrint('Parsed ${events.length} events');
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
@@ -11,27 +11,24 @@ class PrefUtil {
|
||||
}
|
||||
|
||||
static void setValue(String key, Object value) {
|
||||
switch (value.runtimeType) {
|
||||
case String:
|
||||
preferences.setString(key, value as String);
|
||||
break;
|
||||
case bool:
|
||||
preferences.setBool(key, value as bool);
|
||||
break;
|
||||
case int:
|
||||
preferences.setInt(key, value as int);
|
||||
break;
|
||||
switch (value) {
|
||||
case String s:
|
||||
preferences.setString(key, s);
|
||||
case bool b:
|
||||
preferences.setBool(key, b);
|
||||
case int i:
|
||||
preferences.setInt(key, i);
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
static Object getValue(String key, Object defaultValue) {
|
||||
switch (defaultValue.runtimeType) {
|
||||
case String:
|
||||
switch (defaultValue) {
|
||||
case String _:
|
||||
return preferences.getString(key) ?? defaultValue;
|
||||
case bool:
|
||||
case bool _:
|
||||
return preferences.getBool(key) ?? defaultValue;
|
||||
case int:
|
||||
case int _:
|
||||
return preferences.getInt(key) ?? defaultValue;
|
||||
default:
|
||||
return defaultValue;
|
||||
|
||||
Reference in New Issue
Block a user