added station data
This commit is contained in:
parent
f32faad118
commit
a655c789bc
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,8 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const HomeScreen({Key? key}) : super(key: key);
|
const HomeScreen({Key? key}) : super(key: key);
|
||||||
|
@ -8,6 +12,24 @@ class HomeScreen extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeScreenState extends State<HomeScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
|
List _stations = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_getStations();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getStations() async {
|
||||||
|
final String stationFile =
|
||||||
|
await rootBundle.loadString("assets/data/stations.json");
|
||||||
|
final data = await json.decode(stationFile);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_stations = data["records"];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -25,6 +47,41 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () => {print("deez")}, child: const Icon(Icons.add)),
|
onPressed: () => {print("deez")}, child: const Icon(Icons.add)),
|
||||||
|
body: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: _stations.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Card(
|
||||||
|
elevation: 4.0,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 5.0),
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10.0, horizontal: 25.0),
|
||||||
|
leading: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(children: <TextSpan>[
|
||||||
|
TextSpan(text: "เลขขบวน"),
|
||||||
|
TextSpan(text: "\n"),
|
||||||
|
TextSpan(
|
||||||
|
text: _stations[index][1],
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20, fontWeight: FontWeight.bold)),
|
||||||
|
])),
|
||||||
|
title: Text(_stations[index][2]),
|
||||||
|
subtitle: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: <TextSpan>[
|
||||||
|
TextSpan(text: "Arrival: "),
|
||||||
|
TextSpan(text: _stations[index][8]),
|
||||||
|
TextSpan(text: "\n"),
|
||||||
|
TextSpan(text: "Departure: "),
|
||||||
|
TextSpan(text: _stations[index][9])
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
},
|
||||||
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,12 @@ import Foundation
|
||||||
|
|
||||||
import dynamic_color
|
import dynamic_color
|
||||||
import flutter_localization
|
import flutter_localization
|
||||||
|
import path_provider_foundation
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||||
FlutterLocalizationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalizationPlugin"))
|
FlutterLocalizationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalizationPlugin"))
|
||||||
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: srt_app
|
name: srt_app
|
||||||
description: "A new Flutter project."
|
description: "An open source alternative to SRT Timetable."
|
||||||
# The following line prevents the package from being accidentally published to
|
# The following line prevents the package from being accidentally published to
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
@ -38,6 +38,7 @@ dependencies:
|
||||||
dynamic_color: ^1.7.0
|
dynamic_color: ^1.7.0
|
||||||
flutter_localization: ^0.2.2
|
flutter_localization: ^0.2.2
|
||||||
gestures: ^1.0.0
|
gestures: ^1.0.0
|
||||||
|
path_provider: ^2.1.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -62,8 +63,8 @@ flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
assets:
|
||||||
# - images/a_dot_burr.jpeg
|
- assets/data/stations.json
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
|
|
Loading…
Reference in New Issue