refactor: print() durch debugPrint() ersetzen (avoid_print Lint)
65 flutter-analyze-Meldungen behoben, indem alle print()-Aufrufe in Core- Dateien (Push, LiveKit, Matrix-Client, VoIP, Screen-Share) durch das Flutter-eigene debugPrint() ersetzt wurden. Gleiche Funktion (Logging in Debug-Sessions), aber zeilenlängen-sicher und ohne Lint-Warnung. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@@ -72,61 +73,61 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
IsolateNameServer.registerPortWithName(
|
||||
_mainIsolatePort!.sendPort, kMainIsolateName);
|
||||
_mainIsolatePort!.listen((msg) => _onIsolateMessage(msg, ref));
|
||||
print('[NOTIF] IsolateNameServer port registered: $kMainIsolateName');
|
||||
debugPrint('[NOTIF] IsolateNameServer port registered: $kMainIsolateName');
|
||||
|
||||
await _androidPlugin.initialize(
|
||||
const InitializationSettings(
|
||||
android: AndroidInitializationSettings('@drawable/ic_notification'),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (details) {
|
||||
print('[NOTIF-FG] onDidReceiveNotificationResponse fired');
|
||||
print('[NOTIF-FG] actionId=${details.actionId} payload=${details.payload} input=${details.input}');
|
||||
debugPrint('[NOTIF-FG] onDidReceiveNotificationResponse fired');
|
||||
debugPrint('[NOTIF-FG] actionId=${details.actionId} payload=${details.payload} input=${details.input}');
|
||||
if (details.actionId == 'reply') {
|
||||
final text = details.input?.trim() ?? '';
|
||||
final roomId = details.payload;
|
||||
print('[NOTIF-FG] reply: text="$text" roomId=$roomId');
|
||||
debugPrint('[NOTIF-FG] reply: text="$text" roomId=$roomId');
|
||||
if (text.isNotEmpty && roomId != null && roomId.isNotEmpty) {
|
||||
_androidPlugin.cancel(_stableRoomId(roomId));
|
||||
ref.read(matrixClientProvider.future).then((client) async {
|
||||
final room = client.getRoomById(roomId);
|
||||
print('[NOTIF-FG] getRoomById → ${room != null ? 'found' : 'null'}');
|
||||
debugPrint('[NOTIF-FG] getRoomById → ${room != null ? 'found' : 'null'}');
|
||||
if (room != null) {
|
||||
try {
|
||||
await room.sendTextEvent(text);
|
||||
print('[NOTIF-FG] sendTextEvent OK');
|
||||
debugPrint('[NOTIF-FG] sendTextEvent OK');
|
||||
} catch (e) {
|
||||
print('[NOTIF-FG] sendTextEvent failed: $e — storing in prefs');
|
||||
debugPrint('[NOTIF-FG] sendTextEvent failed: $e — storing in prefs');
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('notif_pending_reply_room', roomId);
|
||||
await prefs.setString('notif_pending_reply_text', text);
|
||||
}
|
||||
} else {
|
||||
print('[NOTIF-FG] room null — storing in prefs, waiting for sync');
|
||||
debugPrint('[NOTIF-FG] room null — storing in prefs, waiting for sync');
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('notif_pending_reply_room', roomId);
|
||||
await prefs.setString('notif_pending_reply_text', text);
|
||||
try {
|
||||
await client.onSync.stream.first;
|
||||
print('[NOTIF-FG] sync arrived — retrying _sendPendingReply');
|
||||
debugPrint('[NOTIF-FG] sync arrived — retrying _sendPendingReply');
|
||||
await _sendPendingReply(ref);
|
||||
} catch (e) {
|
||||
print('[NOTIF-FG] sync/send error: $e');
|
||||
debugPrint('[NOTIF-FG] sync/send error: $e');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
print('[NOTIF-FG] reply skipped: text empty or roomId null');
|
||||
debugPrint('[NOTIF-FG] reply skipped: text empty or roomId null');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (details.actionId == 'read') {
|
||||
final roomId = details.payload;
|
||||
if (roomId != null) _androidPlugin.cancel(_stableRoomId(roomId));
|
||||
print('[NOTIF-FG] read action — dismissed');
|
||||
debugPrint('[NOTIF-FG] read action — dismissed');
|
||||
return;
|
||||
}
|
||||
final roomId = details.payload;
|
||||
print('[NOTIF-FG] tap → opening room $roomId');
|
||||
debugPrint('[NOTIF-FG] tap → opening room $roomId');
|
||||
if (roomId != null && roomId.isNotEmpty) {
|
||||
ref.read(activeRoomIdProvider.notifier).state = roomId;
|
||||
ref.read(viewModeProvider.notifier).state = ViewMode.chat;
|
||||
@@ -145,7 +146,7 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
final args = call.arguments;
|
||||
if (call.method == 'openRoom') {
|
||||
final roomId = (args is Map ? args['room_id'] : null) as String?;
|
||||
print('[NOTIF-FG] openRoom: $roomId');
|
||||
debugPrint('[NOTIF-FG] openRoom: $roomId');
|
||||
if (roomId != null && roomId.isNotEmpty) {
|
||||
ref.read(activeRoomIdProvider.notifier).state = roomId;
|
||||
ref.read(viewModeProvider.notifier).state = ViewMode.chat;
|
||||
@@ -156,7 +157,7 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
// MethodChannel — no Activity was opened.
|
||||
final roomId = (args is Map ? args['room_id'] : null) as String?;
|
||||
final text = (args is Map ? args['text'] : null) as String?;
|
||||
print('[NOTIF-FG] replyFromNotification: room=$roomId text=$text');
|
||||
debugPrint('[NOTIF-FG] replyFromNotification: room=$roomId text=$text');
|
||||
if (roomId != null && roomId.isNotEmpty && text != null && text.isNotEmpty) {
|
||||
_androidPlugin.cancel(_stableRoomId(roomId));
|
||||
Future<void> storePending() async {
|
||||
@@ -170,9 +171,9 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
final room = client.getRoomById(roomId);
|
||||
if (room != null) {
|
||||
await room.sendTextEvent(text);
|
||||
print('[NOTIF-FG] replyFromNotification: sent OK');
|
||||
debugPrint('[NOTIF-FG] replyFromNotification: sent OK');
|
||||
} else {
|
||||
print('[NOTIF-FG] replyFromNotification: room null, storing in prefs');
|
||||
debugPrint('[NOTIF-FG] replyFromNotification: room null, storing in prefs');
|
||||
await storePending();
|
||||
// Retry on the next sync — room list is populated after first sync.
|
||||
client.onSync.stream.first
|
||||
@@ -180,7 +181,7 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
.catchError((_) {});
|
||||
}
|
||||
} catch (e) {
|
||||
print('[NOTIF-FG] replyFromNotification error: $e — storing in prefs');
|
||||
debugPrint('[NOTIF-FG] replyFromNotification error: $e — storing in prefs');
|
||||
await storePending();
|
||||
// Resume-based retry (checkPendingReply in app.dart) will pick this up.
|
||||
}
|
||||
@@ -225,7 +226,7 @@ Future<void> _initAndroid(WidgetRef ref) async {
|
||||
if (reply is Map) {
|
||||
final roomId = reply['room_id'] as String?;
|
||||
final text = reply['text'] as String?;
|
||||
print('[NOTIF-REPLY] getInitialReply: roomId=$roomId text=$text');
|
||||
debugPrint('[NOTIF-REPLY] getInitialReply: roomId=$roomId text=$text');
|
||||
if (roomId != null && roomId.isNotEmpty && text != null && text.isNotEmpty) {
|
||||
// Persist so _sendPendingReply sends it after the first sync.
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -302,7 +303,7 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) {
|
||||
final input = message['input'] as String?;
|
||||
final id = message['id'] as int?;
|
||||
|
||||
print('[NOTIF-ISOLATE] action=$actionId payload=$payload input=$input');
|
||||
debugPrint('[NOTIF-ISOLATE] action=$actionId payload=$payload input=$input');
|
||||
|
||||
switch (actionId) {
|
||||
case 'reply':
|
||||
@@ -315,9 +316,9 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) {
|
||||
if (room != null) {
|
||||
try {
|
||||
await room.sendTextEvent(text);
|
||||
print('[NOTIF-ISOLATE] reply sent OK');
|
||||
debugPrint('[NOTIF-ISOLATE] reply sent OK');
|
||||
} catch (e) {
|
||||
print('[NOTIF-ISOLATE] sendTextEvent failed: $e — storing in prefs');
|
||||
debugPrint('[NOTIF-ISOLATE] sendTextEvent failed: $e — storing in prefs');
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('notif_pending_reply_room', roomId);
|
||||
await prefs.setString('notif_pending_reply_text', text);
|
||||
@@ -326,7 +327,7 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) {
|
||||
.catchError((_) {});
|
||||
}
|
||||
} else {
|
||||
print('[NOTIF-ISOLATE] room not in memory — storing in prefs');
|
||||
debugPrint('[NOTIF-ISOLATE] room not in memory — storing in prefs');
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('notif_pending_reply_room', roomId);
|
||||
await prefs.setString('notif_pending_reply_text', text);
|
||||
@@ -342,14 +343,14 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) {
|
||||
} else if (id != null) {
|
||||
_androidPlugin.cancel(id);
|
||||
}
|
||||
print('[NOTIF-ISOLATE] read → notification dismissed');
|
||||
debugPrint('[NOTIF-ISOLATE] read → notification dismissed');
|
||||
|
||||
default:
|
||||
// Plain notification tap → navigate to room.
|
||||
if (payload != null && payload.isNotEmpty) {
|
||||
ref.read(activeRoomIdProvider.notifier).state = payload;
|
||||
ref.read(viewModeProvider.notifier).state = ViewMode.chat;
|
||||
print('[NOTIF-ISOLATE] tap → navigated to $payload');
|
||||
debugPrint('[NOTIF-ISOLATE] tap → navigated to $payload');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,16 +362,16 @@ Future<void> _sendPendingReply(WidgetRef ref) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final roomId = prefs.getString('notif_pending_reply_room');
|
||||
final text = prefs.getString('notif_pending_reply_text');
|
||||
print('[NOTIF-REPLY] _sendPendingReply: roomId=$roomId text=$text');
|
||||
debugPrint('[NOTIF-REPLY] _sendPendingReply: roomId=$roomId text=$text');
|
||||
if (roomId == null || text == null || text.isEmpty) return;
|
||||
|
||||
final client = await ref.read(matrixClientProvider.future);
|
||||
print('[NOTIF-REPLY] client ready, rooms=${client.rooms.length}');
|
||||
debugPrint('[NOTIF-REPLY] client ready, rooms=${client.rooms.length}');
|
||||
|
||||
final room = client.getRoomById(roomId);
|
||||
print('[NOTIF-REPLY] getRoomById → ${room != null ? 'found' : 'null'}');
|
||||
debugPrint('[NOTIF-REPLY] getRoomById → ${room != null ? 'found' : 'null'}');
|
||||
if (room == null) {
|
||||
print('[NOTIF-REPLY] room not in memory yet, retrying after next sync');
|
||||
debugPrint('[NOTIF-REPLY] room not in memory yet, retrying after next sync');
|
||||
client.onSync.stream.first
|
||||
.then((_) => _sendPendingReply(ref))
|
||||
.catchError((_) {});
|
||||
@@ -378,11 +379,11 @@ Future<void> _sendPendingReply(WidgetRef ref) async {
|
||||
}
|
||||
|
||||
await room.sendTextEvent(text);
|
||||
print('[NOTIF-REPLY] sendTextEvent OK, clearing prefs');
|
||||
debugPrint('[NOTIF-REPLY] sendTextEvent OK, clearing prefs');
|
||||
await prefs.remove('notif_pending_reply_room');
|
||||
await prefs.remove('notif_pending_reply_text');
|
||||
} catch (e) {
|
||||
print('[NOTIF-REPLY] error: $e — prefs kept for retry');
|
||||
debugPrint('[NOTIF-REPLY] error: $e — prefs kept for retry');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +460,7 @@ Future<void> _decryptAndUpdateNotification(
|
||||
.timeout(const Duration(seconds: 5));
|
||||
var room = client.getRoomById(roomId);
|
||||
if (room == null) {
|
||||
print('[NOTIF] decryptAndUpdate: room $roomId not found');
|
||||
debugPrint('[NOTIF] decryptAndUpdate: room $roomId not found');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,7 +470,7 @@ Future<void> _decryptAndUpdateNotification(
|
||||
final bool alreadyHave =
|
||||
eventId == null || event?.eventId == eventId;
|
||||
if (!alreadyHave || event == null) {
|
||||
print('[NOTIF] decryptAndUpdate: waiting for sync to deliver $eventId');
|
||||
debugPrint('[NOTIF] decryptAndUpdate: waiting for sync to deliver $eventId');
|
||||
await client.onSync.stream.first.timeout(const Duration(seconds: 12));
|
||||
room = client.getRoomById(roomId);
|
||||
if (room == null) return;
|
||||
@@ -477,7 +478,7 @@ Future<void> _decryptAndUpdateNotification(
|
||||
}
|
||||
|
||||
if (event == null) {
|
||||
print('[NOTIF] decryptAndUpdate: event still null after sync');
|
||||
debugPrint('[NOTIF] decryptAndUpdate: event still null after sync');
|
||||
return;
|
||||
}
|
||||
if (event.type != EventTypes.Message) return;
|
||||
@@ -486,7 +487,7 @@ Future<void> _decryptAndUpdateNotification(
|
||||
final rawBody = event.body;
|
||||
// If decryption failed the body starts with "** Unable to decrypt"
|
||||
if (rawBody.isEmpty || rawBody.startsWith('**')) {
|
||||
print('[NOTIF] decryptAndUpdate: decryption failed, keeping placeholder');
|
||||
debugPrint('[NOTIF] decryptAndUpdate: decryption failed, keeping placeholder');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -507,9 +508,9 @@ Future<void> _decryptAndUpdateNotification(
|
||||
'roomId': roomId,
|
||||
'notifId': notifId ?? _stableRoomId(roomId),
|
||||
});
|
||||
print('[NOTIF] decryptAndUpdate: updated notification → "$title: $notifBody"');
|
||||
debugPrint('[NOTIF] decryptAndUpdate: updated notification → "$title: $notifBody"');
|
||||
} catch (e) {
|
||||
print('[NOTIF] decryptAndUpdate error: $e');
|
||||
debugPrint('[NOTIF] decryptAndUpdate error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +534,7 @@ Future<void> showMessageNotification({
|
||||
'notifId': _stableRoomId(roomId),
|
||||
});
|
||||
} catch (e) {
|
||||
print('[NOTIF] showNativeNotification failed: $e');
|
||||
debugPrint('[NOTIF] showNativeNotification failed: $e');
|
||||
}
|
||||
} else if (Platform.isWindows) {
|
||||
// Close the previous notification for this room before showing a new one.
|
||||
|
||||
Reference in New Issue
Block a user