runs in browser now
This commit is contained in:
parent
373fd0484c
commit
5fb7ff92f5
|
@ -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,
|
||||
|
|
|
@ -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++) {
|
||||
|
|
Loading…
Reference in New Issue