diff --git a/lib/controller/queue_controller.dart b/lib/controller/queue_controller.dart index 1892180f..5530c5af 100644 --- a/lib/controller/queue_controller.dart +++ b/lib/controller/queue_controller.dart @@ -1,4 +1,5 @@ import 'dart:collection'; +import 'dart:convert'; import 'dart:io'; import 'package:namida/class/queue.dart'; @@ -261,13 +262,21 @@ class QueueController { } Future _saveLatestQueueToStorage(List items) async { - final queueObjects = []; + final queueObjects = items + .map((e) => { + 'p': e.toJson(), + 't': _LatestQueueSaver._typesMapLookup[e.runtimeType], + }) + .toList(); - items.loop((e) => queueObjects.add({ - 'p': e.toJson(), - 't': _LatestQueueSaver._typesMapLookup[e.runtimeType], - })); - await File(AppPaths.LATEST_QUEUE).writeAsJson(queueObjects); + try { + final file = File(AppPaths.LATEST_QUEUE); + file.createSync(recursive: true); + const encoder = JsonEncoder(); + await file.writeAsString(encoder.convert(queueObjects)); + } catch (e) { + printy(e, isError: true); + } } Future _deleteQueueFromStorage(Queue queue) async { diff --git a/pubspec.yaml b/pubspec.yaml index 6cba80fc..c27fc02e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: namida description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter publish_to: "none" -version: 4.7.26-beta+241126183 +version: 4.7.27-beta+241126185 environment: sdk: ">=3.4.0 <4.0.0"