11import 'dart:convert' ;
22
3+ import 'package:flutter/material.dart' ;
34import 'package:flutter_secure_storage/flutter_secure_storage.dart' ;
45import 'package:piwigo_ng/models/album_model.dart' ;
56import 'package:piwigo_ng/models/status_model.dart' ;
@@ -246,13 +247,17 @@ class AutoUploadPreferences {
246247 static const String destinationKey = 'AUTO_UPLOAD_DESTINATION' ;
247248
248249 static AlbumModel ? get getDestination {
249- String ? albumJson = appPreferences.getString (destinationKey);
250- if (albumJson == null ) return null ;
251- return AlbumModel .fromJson (json.decode (albumJson));
250+ try {
251+ String ? albumJson = appPreferences.getString (destinationKey);
252+ if (albumJson == null ) return null ;
253+ return AlbumModel .fromJson (json.decode (albumJson));
254+ } on Error catch (e) {
255+ debugPrint ("$e \n ${e .stackTrace }" );
256+ return null ;
257+ }
252258 }
253259
254260 static Future <bool > setDestination (AlbumModel album) async {
255- print (json.encode (album.toJson ()));
256261 return appPreferences.setString (
257262 destinationKey, json.encode (album.toJson ()));
258263 }
@@ -266,7 +271,7 @@ class AutoUploadPreferences {
266271 }
267272
268273 static Future <bool > setFrequency (Duration duration) async {
269- return appPreferences.setInt (destinationKey , duration.inHours);
274+ return appPreferences.setInt (frequencyKey , duration.inHours);
270275 }
271276
272277 static const String notificationKey = 'AUTO_UPLOAD_NOTIFICATION' ;
0 commit comments