У нас вы можете посмотреть бесплатно Flutter Inventory Management: Read from a json assets file, write to a local file and add to a Rive или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: / ky.emrah Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Flutter Inventory Management: Read from a json assets file, write to a local file and add to a Riverpod managed list of items I am trying to learn Flutter through implementation of an inventory app. My app currently reads a list of items from a json file, managed by riverpod, this part works. I also read that Flutter does not allow writing to assets, so I wrote an insertItem() method that writes to a local file and also adds the new item to the managed current Items list. Neither of them are being generated, with no errors. I just see 'Item Added' snack bar, Inventory List is same in the inventory list screen and also file is not in the local device file explorer. I will try to briefly add the relevant parts of the code, let me know if wish to see some other parts. Reading from Json assets file part works fine. @riverpod class JsonInventoryService extends _$JsonInventoryService { late Future List Item _currentItems; late InventoryResult inventoryResult; @override Future List Item build() { return Future.value([Item(id: 0, productName: 'NULL ITEM'),]); } Future loadItems() async { var jsonString = await rootBundle.loadString('assets/inventorylist.json'); inventoryResult = InventoryResult.fromJson(jsonDecode(jsonString)); _currentItems = Future.value(inventoryResultsToItems(inventoryResult)); } Future List Item fetchData() async { return _currentItems; } @riverpod class JsonInventoryService extends _$JsonInventoryService { late Future List Item _currentItems; late InventoryResult inventoryResult; @override Future List Item build() { return Future.value([Item(id: 0, productName: 'NULL ITEM'),]); } Future loadItems() async { var jsonString = await rootBundle.loadString('assets/inventorylist.json'); inventoryResult = InventoryResult.fromJson(jsonDecode(jsonString)); _currentItems = Future.value(inventoryResultsToItems(inventoryResult)); } Future List Item fetchData() async { return _currentItems; } INSERT ITEM METHOD: INSERT ITEM METHOD: Map String, dynamic insertItem(Item item) { inventoryResult.results.add(item); final jsonmap = inventoryResult.toJson(); //json_serializable automatically handles nested class storage.writeFile(jsonmap); return jsonmap; } } Map String, dynamic insertItem(Item item) { inventoryResult.results.add(item); final jsonmap = inventoryResult.toJson(); //json_serializable automatically handles nested class storage.writeFile(jsonmap); return jsonmap; } } Inventory Result is just a model class that has areas for item properties and toJson, fromJson that is being managed by json_serializable. Storage class: class Storage { Future String get _localPath async { final directory = await getApplicationDocumentsDirectory(); return directory.path; } Future File get _localFile async { final path = await _localPath; return File('$path/inventorylist.json'); } Future File writeFile(dynamic jsonmap) async { final file = await _localFile; return file.writeAsString('$jsonmap'); } } class Storage { Future String get _localPath async { final directory = await getApplicationDocumentsDirectory(); return directory.path; } Future File get _localFile async { final path = await _localPath; return File('$path/inventorylist.json'); } Future File writeFile(dynamic jsonmap) async { final file = await _localFile; return file.writSource of the question: https://stackoverflow.com/questions/7... Question and source license information: https://meta.stackexchange.com/help/l... https://stackoverflow.com/