mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 02:59:28 +00:00
This commit is contained in:
parent
2fd4650bb8
commit
edf7b2790f
9 changed files with 141 additions and 189 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive_io.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
|
@ -28,11 +29,23 @@ class Logs extends _$Logs {
|
|||
}
|
||||
|
||||
Future<String> getZipFilePath() async {
|
||||
final String targetZipPath = await generateZipFilePath();
|
||||
var encoder = ZipFileEncoder();
|
||||
encoder.create(await generateZipFilePath());
|
||||
encoder.addFile(File(await getLoggingFilePath()));
|
||||
encoder.close();
|
||||
return encoder.zipPath;
|
||||
encoder.create(targetZipPath);
|
||||
final logFilePath = await getLoggingFilePath();
|
||||
final logFile = File(logFilePath);
|
||||
if (await logFile.exists()) {
|
||||
// Check if log file exists before adding
|
||||
await encoder.addFile(logFile);
|
||||
} else {
|
||||
// Handle case where log file doesn't exist? Maybe log a warning?
|
||||
// Or create an empty file inside the zip? For now, just don't add.
|
||||
debugPrint(
|
||||
'Warning: Log file not found at $logFilePath, creating potentially empty zip.',
|
||||
);
|
||||
}
|
||||
await encoder.close();
|
||||
return targetZipPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'logs_provider.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$logsHash() => r'901376741d17ddbb889d1b7b96bc2882289720a0';
|
||||
String _$logsHash() => r'aa9d3d56586cba6ddf69615320ea605d071ea5e2';
|
||||
|
||||
/// See also [Logs].
|
||||
@ProviderFor(Logs)
|
||||
|
|
|
|||
|
|
@ -28,64 +28,3 @@ void useTimer(VoidCallback callback, Duration delay) {
|
|||
[delay],
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates [FixedExtentScrollController] that will be disposed automatically.
|
||||
///
|
||||
/// See also:
|
||||
/// - [FixedExtentScrollController]
|
||||
FixedExtentScrollController useFixedExtentScrollController({
|
||||
String? debugLabel,
|
||||
List<Object?>? keys,
|
||||
int initialItem = 0,
|
||||
void Function(ScrollPosition)? onAttach,
|
||||
void Function(ScrollPosition)? onDetach,
|
||||
}) {
|
||||
return use(
|
||||
_FixedExtentScrollControllerHook(
|
||||
debugLabel: debugLabel,
|
||||
keys: keys,
|
||||
initialItem: initialItem,
|
||||
onAttach: onAttach,
|
||||
onDetach: onDetach,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _FixedExtentScrollControllerHook
|
||||
extends Hook<FixedExtentScrollController> {
|
||||
const _FixedExtentScrollControllerHook({
|
||||
this.debugLabel,
|
||||
super.keys,
|
||||
required this.initialItem,
|
||||
this.onAttach,
|
||||
this.onDetach,
|
||||
});
|
||||
|
||||
final int initialItem;
|
||||
final void Function(ScrollPosition)? onAttach;
|
||||
final void Function(ScrollPosition)? onDetach;
|
||||
|
||||
final String? debugLabel;
|
||||
|
||||
@override
|
||||
HookState<FixedExtentScrollController, Hook<FixedExtentScrollController>>
|
||||
createState() => _FixedExtentScrollControllerHookState();
|
||||
}
|
||||
|
||||
class _FixedExtentScrollControllerHookState extends HookState<
|
||||
FixedExtentScrollController, _FixedExtentScrollControllerHook> {
|
||||
late final controller = FixedExtentScrollController(
|
||||
initialItem: hook.initialItem,
|
||||
onAttach: hook.onAttach,
|
||||
onDetach: hook.onDetach,
|
||||
);
|
||||
|
||||
@override
|
||||
FixedExtentScrollController build(BuildContext context) => controller;
|
||||
|
||||
@override
|
||||
void dispose() => controller.dispose();
|
||||
|
||||
@override
|
||||
String get debugLabel => 'useFixedExtentScrollController';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue