This repository has been archived by the owner on Aug 15, 2021. It is now read-only.
/
main.dart
73 lines (66 loc) · 2 KB
/
main.dart
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:location/location.dart';
import 'package:mapbox_gl_example/full_map.dart';
import 'animate_camera.dart';
import 'full_map.dart';
import 'line.dart';
import 'map_ui.dart';
import 'move_camera.dart';
import 'page.dart';
import 'place_circle.dart';
import 'place_source.dart';
import 'place_symbol.dart';
import 'place_fill.dart';
import 'scrolling_map.dart';
final List<ExamplePage> _allPages = <ExamplePage>[
MapUiPage(),
FullMapPage(),
AnimateCameraPage(),
MoveCameraPage(),
PlaceSymbolPage(),
PlaceSourcePage(),
LinePage(),
PlaceCirclePage(),
PlaceFillPage(),
ScrollingMapPage(),
];
class MapsDemo extends StatelessWidget {
//FIXME: Add your Cedarmaps credentials here
static const String CLIENT_ID = "CLIENT_ID";
static const String CLIENT_SECRET = "CLIENT_SECRET";
void _pushPage(BuildContext context, ExamplePage page) async {
if (!kIsWeb) {
final location = Location();
final hasPermissions = await location.hasPermission();
if (hasPermissions != PermissionStatus.GRANTED) {
await location.requestPermission();
}
}
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (_) => Scaffold(
appBar: AppBar(title: Text(page.title)),
body: page,
)));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Cedarmaps examples')),
body: ListView.builder(
itemCount: _allPages.length,
itemBuilder: (_, int index) => ListTile(
leading: _allPages[index].leading,
title: Text(_allPages[index].title),
onTap: () => _pushPage(context, _allPages[index]),
),
),
);
}
}
void main() {
runApp(MaterialApp(home: MapsDemo()));
}