add two views
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ertl_filament_verwaltung/services/get_storage_services.dart';
|
||||
|
||||
class MemoryStorageService extends GetxService implements GetStorageService {
|
||||
final tables = <String, List<Map<String, dynamic>>>{};
|
||||
bool failWrites = false;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
|
||||
@override
|
||||
List<Map<String, dynamic>> getModelList(String key) =>
|
||||
(jsonDecode(jsonEncode(tables[key] ?? [])) as List)
|
||||
.map((item) => Map<String, dynamic>.from(item as Map))
|
||||
.toList();
|
||||
|
||||
@override
|
||||
Future<void> saveModelList(
|
||||
String key,
|
||||
List<Map<String, dynamic>> items,
|
||||
) async {
|
||||
if (failWrites) throw StateError('Storage unavailable');
|
||||
tables[key] = items;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user