init
This commit is contained in:
commit
2379b4476f
141 files changed
+6087
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class FileDirectoryHistory {
|
||||
final String? rootPath;
|
||||
final String? lastOpenedFilePath;
|
||||
final List<String> openDirectoryPaths;
|
||||
|
||||
const FileDirectoryHistory({
|
||||
required this.rootPath,
|
||||
required this.lastOpenedFilePath,
|
||||
this.openDirectoryPaths = const [],
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'rootPath': rootPath,
|
||||
'lastOpenedFilePath': lastOpenedFilePath,
|
||||
'openDirectoryPaths': openDirectoryPaths,
|
||||
};
|
||||
|
||||
factory FileDirectoryHistory.fromMap(Map<String, dynamic> map) {
|
||||
return FileDirectoryHistory(
|
||||
rootPath: map['rootPath'] as String?,
|
||||
lastOpenedFilePath: map['lastOpenedFilePath'] as String?,
|
||||
openDirectoryPaths: (map['openDirectoryPaths'] as List<dynamic>?)
|
||||
?.map((e) => e.toString())
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => jsonEncode(toMap());
|
||||
factory FileDirectoryHistory.fromJson(String source) {
|
||||
try {
|
||||
final decoded = jsonDecode(source);
|
||||
if (decoded is Map) {
|
||||
return FileDirectoryHistory.fromMap(Map<String, dynamic>.from(decoded));
|
||||
}
|
||||
} catch (_) {}
|
||||
return const FileDirectoryHistory(rootPath: null, lastOpenedFilePath: null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user