-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
94 lines (82 loc) · 2.77 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) 2020-2023 Navibyte (https://navibyte.com). All rights reserved.
// Use of this source code is governed by a “BSD-3-Clause”-style license that is
// specified in the LICENSE file.
//
// Docs: https://github.com/navibyte/geospatial_demos
/*
Instructions to setup Google Maps for Flutter
https://pub.dev/packages/google_maps_flutter
Set the minSdkVersion to SDK 20
- android/app/build.gradle
- android -> defaultConfig -> minSdkVersion 20
- android/app/src/main/AndroidManifest.xml
- manifest -> application ->
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="<YOUR-APIKEY>"/>
- ios/Runner/AppDelegate.swift
- import GoogleMaps
- AppDelegate -> application
GMSServices.provideAPIKey("<YOUR-APIKEY>")
See also instructions to set up Google Maps for Flutter to work on web platfrom:
https://pub.dev/packages/google_maps_flutter_web
web/index.hml should include:
<script
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=drawing">
</script>
*/
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '/src/map/map_view.dart';
import '/src/settings/settings_view.dart';
void main() {
runApp(const EarthquakeMapApp());
}
/// The app widget showing the main view with a map.
class EarthquakeMapApp extends StatelessWidget {
const EarthquakeMapApp({super.key});
@override
Widget build(BuildContext context) {
/// The `ProviderScope` is required by Riverpod for state management.
return ProviderScope(
child: MaterialApp(
title: 'Earthquake Map',
theme: ThemeData(),
home: const AppView(),
),
);
}
}
/// The app view with simple appbar, a button on the appbar to show settings,
/// and a map view showing world map and earthquakes as markers.
class AppView extends StatelessWidget {
const AppView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Earthquake Map'),
actions: [
IconButton(
icon: const Icon(Icons.settings),
tooltip: 'Settings',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) {
// The settings view shows a selection for units and filter
// parameters for querying earthquakes.
return const SettingsView();
},
),
);
},
),
],
),
// The map view showing Google Maps and earthquakes as markers. Data is
// retrieved from the USGS service (GeoJSON).
body: const MapView(),
);
}
}