-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathapp.dart
More file actions
40 lines (32 loc) · 884 Bytes
/
app.dart
File metadata and controls
40 lines (32 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
const ACCESS_TOKEN = String.fromEnvironment('ACCESS_TOKEN');
Future<MapboxMap> main(
{double? width,
double? height,
CameraOptions? camera,
Alignment alignment = Alignment.topLeft}) {
final completer = Completer<MapboxMap>();
MapboxOptions.setAccessToken(ACCESS_TOKEN);
runApp(MaterialApp(
home: Align(
alignment: alignment,
child: SizedBox(
width: width,
height: height,
child: MapWidget(
key: ValueKey("mapWidget"),
cameraOptions: camera,
onMapCreated: (MapboxMap mapboxMap) {
completer.complete(mapboxMap);
},
),
),
)));
return completer.future;
}
void runEmpty() {
MapboxOptions.setAccessToken(ACCESS_TOKEN);
runApp(MaterialApp());
}