58 lines
1.3 KiB
Dart
58 lines
1.3 KiB
Dart
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:http/http.dart' as http;
|
||
|
import 'package:toolheim/Warband.dart';
|
||
|
import 'package:yaml/yaml.dart';
|
||
|
|
||
|
void main() => runApp(Toolheim());
|
||
|
|
||
|
class Toolheim extends StatelessWidget {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return MaterialApp(
|
||
|
title: 'Toolheim',
|
||
|
theme: ThemeData(
|
||
|
primarySwatch: Colors.brown,
|
||
|
accentColor: Colors.grey,
|
||
|
),
|
||
|
home: RoasterWidget(),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class RoasterWidget extends StatefulWidget {
|
||
|
@override
|
||
|
_RoasterWidgetState createState() => _RoasterWidgetState();
|
||
|
}
|
||
|
|
||
|
class _RoasterWidgetState extends State<RoasterWidget> {
|
||
|
final String urlPath = 'https://raw.githubusercontent.com/Labernator/Mordheim/master/Mordheim-BorderTownBurning/Warband%20Rosters/Aaron/aaron.mordheim.yml';
|
||
|
Warband warband;
|
||
|
|
||
|
Future fetchWarband() async {
|
||
|
http.Response response = await http.get(urlPath);
|
||
|
YamlMap yamlObject = loadYaml(response.body);
|
||
|
Warband _warband = Warband.fromJson(yamlObject);
|
||
|
|
||
|
setState(() {
|
||
|
warband = _warband;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
void initState() {
|
||
|
fetchWarband();
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: Text(warband.name)
|
||
|
),
|
||
|
body: Text(warband.race, textScaleFactor: 1.3)
|
||
|
);
|
||
|
}
|
||
|
}
|