Flutter-Ernaehrungsapp/lib/models/food_dto.dart

13 lines
379 B
Dart
Raw Permalink Normal View History

2023-05-29 12:08:46 +02:00
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();
}
}