Skip to content

Commit fe2af7f

Browse files
committed
chore: big package dumps, remove map_controller dep
1 parent 47a3c1e commit fe2af7f

File tree

4 files changed

+149
-183
lines changed

4 files changed

+149
-183
lines changed

ios/Runner/GeneratedPluginRegistrant.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
@import connectivity_plus;
2525
#endif
2626

27-
#if __has_include(<device_info_plus/FLTDeviceInfoPlusPlugin.h>)
28-
#import <device_info_plus/FLTDeviceInfoPlusPlugin.h>
27+
#if __has_include(<device_info_plus/FPPDeviceInfoPlusPlugin.h>)
28+
#import <device_info_plus/FPPDeviceInfoPlusPlugin.h>
2929
#else
3030
@import device_info_plus;
3131
#endif
@@ -114,7 +114,7 @@ + (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
114114
[Add2CalendarPlugin registerWithRegistrar:[registry registrarForPlugin:@"Add2CalendarPlugin"]];
115115
[BackgroundDownloaderPlugin registerWithRegistrar:[registry registrarForPlugin:@"BackgroundDownloaderPlugin"]];
116116
[ConnectivityPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"ConnectivityPlusPlugin"]];
117-
[FLTDeviceInfoPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTDeviceInfoPlusPlugin"]];
117+
[FPPDeviceInfoPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"FPPDeviceInfoPlusPlugin"]];
118118
[InAppWebViewFlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"InAppWebViewFlutterPlugin"]];
119119
[FluttertoastPlugin registerWithRegistrar:[registry registrarForPlugin:@"FluttertoastPlugin"]];
120120
[FPPPackageInfoPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"FPPPackageInfoPlusPlugin"]];

lib/Screens/circuit_map_screen.dart

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import 'package:flutter/material.dart';
2525
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2626
import 'package:flutter_map/flutter_map.dart';
2727
import 'package:latlong2/latlong.dart';
28-
import 'package:map_controller_plus/map_controller_plus.dart';
2928
import 'package:boxbox/helpers/circuit_points.dart';
3029
import 'package:url_launcher/url_launcher.dart';
3130

@@ -84,89 +83,85 @@ class MarkersPage extends StatefulWidget {
8483
}
8584

8685
class _MarkersPageState extends State<MarkersPage> {
87-
late MapController mapController;
88-
late StatefulMapController statefulMapController;
89-
late StreamSubscription<StatefulMapControllerStateChange> sub;
86+
MapController mapController = MapController();
9087

91-
Future<void> addPoints(String circuitId) async {
88+
Future<List<Polyline>> addPoints(String circuitId) async {
9289
List<List> circuitPointsData =
9390
await GetTrackGeoJSONPoints().getCircuitPoints(
9491
circuitId,
9592
);
9693
List trackPoints = circuitPointsData[0];
97-
List mapCenter = circuitPointsData[1];
98-
99-
statefulMapController.centerOnPoint(
100-
LatLng(mapCenter[0], mapCenter[1]),
101-
);
94+
List<Polyline> parsedPoints = [];
10295

10396
for (final point in trackPoints) {
10497
num diffPointIndex = trackPoints.length - trackPoints.indexOf(point);
10598
if (diffPointIndex.toInt() > 1) {
10699
List secondPoint = trackPoints[trackPoints.indexOf(point) + 1];
107-
statefulMapController.addLine(
108-
name: point.toString(),
109-
points: [
110-
LatLng(
111-
point[1],
112-
point[0],
113-
),
114-
LatLng(
115-
secondPoint[1],
116-
secondPoint[0],
117-
),
118-
],
119-
color: Theme.of(context).colorScheme.onPrimary,
100+
parsedPoints.add(
101+
Polyline(
102+
points: [
103+
LatLng(
104+
point[1],
105+
point[0],
106+
),
107+
LatLng(
108+
secondPoint[1],
109+
secondPoint[0],
110+
),
111+
],
112+
color: Theme.of(context).colorScheme.onPrimary,
113+
strokeWidth: 2.5,
114+
),
120115
);
121116
}
122117
}
123-
return;
118+
119+
return parsedPoints;
124120
}
125121

126122
@override
127123
void initState() {
128-
mapController = MapController();
129-
statefulMapController = StatefulMapController(mapController: mapController);
130-
sub = statefulMapController.changeFeed.listen((change) => setState(() {}));
131-
WidgetsBinding.instance.addPostFrameCallback((_) {
132-
addPoints(widget.circuitId);
133-
});
134124
super.initState();
135125
}
136126

137127
@override
138128
Widget build(BuildContext context) {
139-
return FlutterMap(
140-
mapController: mapController,
141-
options: MapOptions(
142-
zoom: 14.0,
143-
),
144-
nonRotatedChildren: [
145-
RichAttributionWidget(
146-
attributions: [
147-
TextSourceAttribution(
148-
'OpenStreetMap contributors',
149-
onTap: () =>
150-
launchUrl(Uri.parse('https://openstreetmap.org/copyright')),
129+
return FutureBuilder<List<Polyline>>(
130+
future: addPoints(widget.circuitId),
131+
builder: (context, snapshot) {
132+
if (snapshot.data != null) {
133+
mapController.move(snapshot.data![0].points[1], 14.0);
134+
}
135+
return FlutterMap(
136+
mapController: mapController,
137+
options: MapOptions(
138+
initialZoom: 14.0,
139+
),
140+
children: [
141+
RichAttributionWidget(
142+
animationConfig: const ScaleRAWA(),
143+
attributions: [
144+
TextSourceAttribution(
145+
'OpenStreetMap contributors',
146+
onTap: () => launchUrl(
147+
Uri.parse('https://openstreetmap.org/copyright')),
148+
),
149+
],
150+
),
151+
TileLayer(
152+
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
153+
),
154+
PolylineLayer<Object>(
155+
polylines: snapshot.hasData ? snapshot.data! : [],
151156
),
152157
],
153-
),
154-
],
155-
children: [
156-
TileLayer(
157-
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
158-
subdomains: const ['a', 'b', 'c'],
159-
),
160-
PolylineLayer(
161-
polylines: statefulMapController.lines,
162-
),
163-
],
158+
);
159+
},
164160
);
165161
}
166162

167163
@override
168164
void dispose() {
169-
sub.cancel();
170165
super.dispose();
171166
}
172167
}

0 commit comments

Comments
 (0)