runs in browser now
This commit is contained in:
parent
373fd0484c
commit
5fb7ff92f5
|
@ -5,6 +5,8 @@ import './person.dart';
|
||||||
import './about.dart';
|
import './about.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
// refuses to do anything in browser unless this is called
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
List<Person> people = await getPeopleList();
|
List<Person> people = await getPeopleList();
|
||||||
runApp(Senatorialkillers(
|
runApp(Senatorialkillers(
|
||||||
people: people,
|
people: people,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class Person {
|
class Person {
|
||||||
late String img;
|
late String img;
|
||||||
late String name;
|
late String name;
|
||||||
|
@ -23,7 +25,7 @@ class Person {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Person>> getPeopleList() async {
|
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<dynamic> map = jsonDecode(data)["people"];
|
||||||
List<Person> people = [];
|
List<Person> people = [];
|
||||||
for (int i = 0; i < map.length - 1; i++) {
|
for (int i = 0; i < map.length - 1; i++) {
|
||||||
|
|
Loading…
Reference in New Issue