forked from humazed/google_map_location_picker
/
main.dart
77 lines (71 loc) 路 2.43 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
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:google_map_location_picker/generated/l10n.dart'
as location_picker;
import 'package:google_map_location_picker/google_map_location_picker.dart';
import 'package:google_map_location_picker_example/keys.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'generated/i18n.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
LocationResult _pickedLocation;
@override
Widget build(BuildContext context) {
return MaterialApp(
// theme: ThemeData.dark(),
title: 'location picker',
localizationsDelegates: const [
location_picker.S.delegate,
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const <Locale>[
Locale('en', ''),
Locale('ar', ''),
Locale('pt', ''),
Locale('tr', ''),
Locale('es', ''),
Locale('it', ''),
Locale('ru', ''),
],
home: Scaffold(
appBar: AppBar(
title: const Text('location picker'),
),
body: Builder(builder: (context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () async {
LocationResult result = await showLocationPicker(
context, apiKey,
initialCenter: LatLng(31.1975844, 29.9598339),
// automaticallyAnimateToCurrentLocation: true,
// mapStylePath: 'assets/mapStyle.json',
myLocationButtonEnabled: true,
layersButtonEnabled: true,
// countries: ['AE', 'NG']
// resultCardAlignment: Alignment.bottomCenter,
);
print("result = $result");
setState(() => _pickedLocation = result);
},
child: Text('Pick location'),
),
Text(_pickedLocation.toString()),
],
),
);
}),
),
);
}
}