Compare commits
3 Commits
a655c789bc
...
c7a1f130cf
Author | SHA1 | Date |
---|---|---|
Win | c7a1f130cf | |
Win | ffa0c0ff34 | |
Win | 6cfa24f1e3 |
15
.metadata
15
.metadata
|
@ -15,24 +15,9 @@ 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 _stations = [];
|
||||
List _schedule = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_getStations();
|
||||
_getSchedule();
|
||||
}
|
||||
|
||||
Future<void> _getStations() async {
|
||||
final String stationFile =
|
||||
await rootBundle.loadString("assets/data/stations.json");
|
||||
final data = await json.decode(stationFile);
|
||||
Future<void> _getSchedule() async {
|
||||
final String scheduleFile =
|
||||
await rootBundle.loadString("assets/data/schedule.json");
|
||||
final data = await json.decode(scheduleFile);
|
||||
|
||||
setState(() {
|
||||
_stations = data["records"];
|
||||
_schedule = data["records"];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||
body: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: ListView.builder(
|
||||
itemCount: _stations.length,
|
||||
itemCount: _schedule.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: _stations[index][1],
|
||||
text: _schedule[index][1],
|
||||
style: TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
])),
|
||||
title: Text(_stations[index][2]),
|
||||
title: Text(_schedule[index][2]),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: "Arrival: "),
|
||||
TextSpan(text: _stations[index][8]),
|
||||
TextSpan(text: _schedule[index][8]),
|
||||
TextSpan(text: "\n"),
|
||||
TextSpan(text: "Departure: "),
|
||||
TextSpan(text: _stations[index][9])
|
||||
TextSpan(text: _schedule[index][9])
|
||||
],
|
||||
)),
|
||||
));
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
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);
|
||||
|
@ -8,6 +19,48 @@ 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(
|
||||
|
@ -25,6 +78,17 @@ 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,6 +39,10 @@ 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:
|
||||
|
@ -64,6 +68,7 @@ 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