import 'dart:convert'; import 'package:flutter/services.dart'; /// Logging transport is independent of the bridge whose calls it records. class NativeLogSource { const NativeLogSource({ MethodChannel channel = const MethodChannel('com.zarz.spotiflac/backend'), }) : _channel = channel; final MethodChannel _channel; Future> getSince(int index) async { final result = await _channel.invokeMethod('getLogsSince', { 'index': index, }); final decoded = result is String ? (result.isEmpty ? null : jsonDecode(result)) : result; if (decoded is Map) return decoded.cast(); throw FormatException( 'Expected map result from getLogsSince, got ${decoded.runtimeType}', ); } Future setLoggingEnabled(bool enabled) => _channel.invokeMethod('setLoggingEnabled', {'enabled': enabled}); Future clear() => _channel.invokeMethod('clearLogs'); }