add import export and items
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
||||
class BackupFileService {
|
||||
Future<bool> save(String json, String name) async =>
|
||||
await FilePicker.saveFile(
|
||||
dialogTitle: 'Datensicherung speichern',
|
||||
fileName: name,
|
||||
bytes: Uint8List.fromList(utf8.encode(json)),
|
||||
) !=
|
||||
null;
|
||||
|
||||
Future<String?> open() async {
|
||||
final file = await FilePicker.pickFile(
|
||||
dialogTitle: 'Datensicherung auswählen',
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['json'],
|
||||
);
|
||||
if (file == null) return null;
|
||||
return utf8.decode(await file.readAsBytes());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user