Compare commits
No commits in common. "c7a1f130cf693df962f34f6de53fe4848b44ba94" and "a655c789bcd3cf4750e656f9e15347e9883b4553" have entirely different histories.
c7a1f130cf
...
a655c789bc
15
.metadata
15
.metadata
|
@ -15,9 +15,24 @@ migration:
|
|||
- platform: root
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: android
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: ios
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: linux
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: macos
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: web
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
- platform: windows
|
||||
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
|
||||
|
||||
# User provided section
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -12,21 +12,21 @@ class HomeScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
List _schedule = [];
|
||||
List _stations = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_getSchedule();
|
||||
_getStations();
|
||||
}
|
||||
|
||||
Future<void> _getSchedule() async {
|
||||
final String scheduleFile =
|
||||
await rootBundle.loadString("assets/data/schedule.json");
|
||||
final data = await json.decode(scheduleFile);
|
||||
Future<void> _getStations() async {
|
||||
final String stationFile =
|
||||
await rootBundle.loadString("assets/data/stations.json");
|
||||
final data = await json.decode(stationFile);
|
||||
|
||||
setState(() {
|
||||
_schedule = data["records"];
|
||||
_stations = data["records"];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||
body: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: ListView.builder(
|
||||
itemCount: _schedule.length,
|
||||
itemCount: _stations.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
elevation: 4.0,
|
||||
|
@ -64,19 +64,19 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||
TextSpan(text: "เลขขบวน"),
|
||||
TextSpan(text: "\n"),
|
||||
TextSpan(
|
||||
text: _schedule[index][1],
|
||||
text: _stations[index][1],
|
||||
style: TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
])),
|
||||
title: Text(_schedule[index][2]),
|
||||
title: Text(_stations[index][2]),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: "Arrival: "),
|
||||
TextSpan(text: _schedule[index][8]),
|
||||
TextSpan(text: _stations[index][8]),
|
||||
TextSpan(text: "\n"),
|
||||
TextSpan(text: "Departure: "),
|
||||
TextSpan(text: _schedule[index][9])
|
||||
TextSpan(text: _stations[index][9])
|
||||
],
|
||||
)),
|
||||
));
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
}
|
||||
|
||||
class MapScreen extends StatefulWidget {
|
||||
const MapScreen({Key? key}) : super(key: key);
|
||||
|
@ -19,48 +8,6 @@ class MapScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MapScreenState extends State<MapScreen> {
|
||||
List _stations = [];
|
||||
List<Marker> _markers = [];
|
||||
|
||||
@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"];
|
||||
_getMarkers();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _getMarkers() async {
|
||||
List<Marker> markers = [];
|
||||
|
||||
for (var i = 0; i < _stations.length; i++) {
|
||||
markers.add(
|
||||
Marker(
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(double.tryParse(_stations[i][4].toString()) ?? 0,
|
||||
double.tryParse(_stations[i][5].toString()) ?? 0),
|
||||
builder: (ctx) =>
|
||||
const Icon(Icons.pin_drop, color: Colors.brown, size: 50.0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_markers = markers;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -78,17 +25,6 @@ class _MapScreenState extends State<MapScreen> {
|
|||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => {print("deez")}, child: const Icon(Icons.add)),
|
||||
body: FlutterMap(
|
||||
options:
|
||||
MapOptions(center: const LatLng(13.736717, 100.523186), zoom: 10.0),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
//userAgentPackageName: 'net.winscloud.srt',
|
||||
),
|
||||
MarkerLayer(markers: _markers)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,6 @@ dependencies:
|
|||
flutter_localization: ^0.2.2
|
||||
gestures: ^1.0.0
|
||||
path_provider: ^2.1.4
|
||||
flutter_map: any
|
||||
latlong2: any
|
||||
flutter_map_supercluster: any
|
||||
flutter_map_animations: any
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -68,7 +64,6 @@ flutter:
|
|||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/data/schedule.json
|
||||
- assets/data/stations.json
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
|
Loading…
Reference in New Issue