runs in browser now

This commit is contained in:
zoe 2022-08-01 17:24:29 +02:00
parent 373fd0484c
commit 5fb7ff92f5
2 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import './person.dart';
import './about.dart';
void main() async {
// refuses to do anything in browser unless this is called
WidgetsFlutterBinding.ensureInitialized();
List<Person> people = await getPeopleList();
runApp(Senatorialkillers(
people: people,

View File

@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart';
class Person {
late String img;
late String name;
@ -23,7 +25,7 @@ class Person {
}
Future<List<Person>> getPeopleList() async {
String data = await File("assets/data.json").readAsString();
String data = await rootBundle.loadString('assets/data.json');
List<dynamic> map = jsonDecode(data)["people"];
List<Person> people = [];
for (int i = 0; i < map.length - 1; i++) {