Flutter-Ernaehrungsapp/lib/android/models/food_dto.dart

13 lines
379 B
Dart
Raw Normal View History

import 'dart:convert';
import 'food.dart';
import 'package:flutter/services.dart' as root_bundle;
class FoodDTO {
static Future<List<Food>> readJson() async {
final jsonData =
await root_bundle.rootBundle.loadString('assets/json/csvjson_full.json');
final list = json.decode(jsonData) as List<dynamic>;
return list.map((e) => Food.fromJson(e)).toList();
}
}