import 'dart:convert'; import 'dart:io'; import 'package:flutter/services.dart'; import 'package:tangocard_reader/models/data_entry.dart'; // TODO: merge Future>> get tangocardFilePaths => rootBundle .loadString('AssetManifest.json') .then( (json) => jsonDecode(json) .keys .where((String key) => key.contains('yokutango/json/') && key.contains('.json')) .toList(), ) .then( (l) async => Map.fromIterables( l.map((f) => File(f)), await Future.wait>( l.map>>( (String t) => rootBundle.loadString(t).then>( (s) => jsonDecode(s) .map((e) => YokutangoEntry.fromJson(e)) .toList()), )), ), ); Future>> get kanjicardFilePaths => rootBundle .loadString('AssetManifest.json') .then( (json) => jsonDecode(json) .keys .where((String key) => key.contains(RegExp(r'yokutango/kanji/kanji_\d+.json'))) .toList(), ) .then( (l) async => Map.fromIterables( l.map((f) => File(f)), await Future.wait>(l.map>>( (String t) => rootBundle.loadString(t).then>((s) => jsonDecode(s) .map((e) => KanjiEntry.fromJson(e)) .toList()), )), ), );