Prepared for dialog implementation
This commit is contained in:
@@ -11,10 +11,9 @@ class LocalStorageService {
|
||||
/// Speichert GameSessions im App-Dokumentenverzeichnis
|
||||
static Future<void> saveGameSessions() async {
|
||||
try {
|
||||
List<GameSession> sessions = Globals.gameList;
|
||||
final file = await _getLocalFile();
|
||||
final jsonList = sessions.map((session) => session.toJson()).toList();
|
||||
await file.writeAsString(json.encode(jsonList));
|
||||
final jsonFile = getJsonFile();
|
||||
await file.writeAsString(jsonFile);
|
||||
print('Daten gespeichert');
|
||||
} catch (e) {
|
||||
print('Fehler beim Speichern: $e');
|
||||
@@ -49,6 +48,12 @@ class LocalStorageService {
|
||||
}
|
||||
}
|
||||
|
||||
static String getJsonFile() {
|
||||
final jsonFile =
|
||||
Globals.gameList.map((session) => session.toJson()).toList();
|
||||
return json.encode(jsonFile);
|
||||
}
|
||||
|
||||
static Future<File> _getLocalFile() async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
final path = '${directory.path}/$_fileName';
|
||||
|
||||
@@ -80,7 +80,10 @@ class InformationView extends StatelessWidget {
|
||||
Uri.parse('https://www.github.com/flixcoo')),
|
||||
icon: const Icon(FontAwesomeIcons.github)),
|
||||
],
|
||||
)
|
||||
),
|
||||
CupertinoButton(
|
||||
child: const Text('Spieldaten exportieren'),
|
||||
onPressed: () => {saveJsonToDevice()})
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
@@ -112,4 +115,8 @@ class InformationView extends StatelessWidget {
|
||||
],
|
||||
)));
|
||||
}
|
||||
|
||||
void saveJsonToDevice() async {
|
||||
//todo: implement
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user