Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=D:\Testes\google_map_location_picker\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1.0.0"
3 changes: 1 addition & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:google_map_location_picker/generated/i18n.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';
Expand Down Expand Up @@ -49,7 +48,7 @@ class _MyAppState extends State<MyApp> {
onPressed: () async {
LocationResult result = await showLocationPicker(
context,
apiKey,
"Your Api Key",
initialCenter: LatLng(31.1975844, 29.9598339),
// automaticallyAnimateToCurrentLocation: true,
// mapStylePath: 'assets/mapStyle.json',
Expand Down
28 changes: 14 additions & 14 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
Expand All @@ -70,7 +70,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
csslib:
dependency: transitive
description:
Expand Down Expand Up @@ -155,7 +155,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.3.0"
version: "3.3.1"
google_maps_flutter:
dependency: transitive
description:
Expand Down Expand Up @@ -197,14 +197,14 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.0"
version: "0.16.1"
intl_translation:
dependency: "direct main"
description:
Expand Down Expand Up @@ -316,7 +316,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -328,7 +328,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -370,7 +370,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -398,7 +398,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
yaml:
dependency: transitive
description:
Expand Down
42 changes: 29 additions & 13 deletions lib/src/google_map_location_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class LocationPicker extends StatefulWidget {
this.resultCardAlignment,
this.resultCardDecoration,
this.resultCardPadding,
this.customLocationCard,
this.appBar,
this.customPin,
});

final String apiKey;
Expand All @@ -54,7 +57,10 @@ class LocationPicker extends StatefulWidget {
final Alignment resultCardAlignment;
final Decoration resultCardDecoration;
final EdgeInsets resultCardPadding;

final AppBar appBar;
final Function(BuildContext context, LocationProvider locationProvider)
customLocationCard;
final Widget customPin;
@override
LocationPickerState createState() => LocationPickerState();
}
Expand Down Expand Up @@ -362,18 +368,19 @@ class LocationPickerState extends State<LocationPicker> {
child: Builder(builder: (context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
iconTheme: Theme.of(context).iconTheme,
elevation: 0,
backgroundColor: widget.appBarColor,
key: appBarKey,
title: SearchInput(
(input) => searchPlace(input),
key: searchInputKey,
boxDecoration: widget.searchBarBoxDecoration,
hintText: widget.hintText,
),
),
appBar: widget.appBar ??
AppBar(
iconTheme: Theme.of(context).iconTheme,
elevation: 0,
backgroundColor: widget.appBarColor,
key: appBarKey,
title: SearchInput(
(input) => searchPlace(input),
key: searchInputKey,
boxDecoration: widget.searchBarBoxDecoration,
hintText: widget.hintText,
),
),
body: MapPicker(
widget.apiKey,
initialCenter: widget.initialCenter,
Expand All @@ -391,6 +398,8 @@ class LocationPickerState extends State<LocationPicker> {
resultCardDecoration: widget.resultCardDecoration,
resultCardPadding: widget.resultCardPadding,
key: mapKey,
customLocationCard: widget.customLocationCard,
customPin: widget.customPin,
),
);
}),
Expand Down Expand Up @@ -424,6 +433,10 @@ Future<LocationResult> showLocationPicker(
AlignmentGeometry resultCardAlignment,
EdgeInsetsGeometry resultCardPadding,
Decoration resultCardDecoration,
Function(BuildContext context, LocationProvider locationProvider)
customLocationCard,
Widget customPin,
AppBar appBar,
}) async {
final results = await Navigator.of(context).push(
MaterialPageRoute<dynamic>(
Expand All @@ -444,6 +457,9 @@ Future<LocationResult> showLocationPicker(
resultCardAlignment: resultCardAlignment,
resultCardPadding: resultCardPadding,
resultCardDecoration: resultCardDecoration,
customLocationCard: customLocationCard,
appBar: appBar,
customPin: customPin,
);
},
),
Expand Down
103 changes: 58 additions & 45 deletions lib/src/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class MapPicker extends StatefulWidget {
this.resultCardAlignment,
this.resultCardDecoration,
this.resultCardPadding,
this.customLocationCard,
this.customPin,
}) : super(key: key);

final String apiKey;
Expand All @@ -55,6 +57,10 @@ class MapPicker extends StatefulWidget {
final Alignment resultCardAlignment;
final Decoration resultCardDecoration;
final EdgeInsets resultCardPadding;
final Function(BuildContext context, LocationProvider locationProvider)
customLocationCard;

final Widget customPin;

@override
MapPickerState createState() => MapPickerState();
Expand Down Expand Up @@ -186,7 +192,7 @@ class MapPickerState extends State<MapPicker> {
onToggleMapTypePressed: _onToggleMapTypePressed,
onMyLocationPressed: _initCurrentLocation,
),
pin(),
widget.customPin ?? pin(),
locationCard(),
],
),
Expand All @@ -198,52 +204,59 @@ class MapPickerState extends State<MapPicker> {
alignment: widget.resultCardAlignment ?? Alignment.bottomCenter,
child: Padding(
padding: widget.resultCardPadding ?? EdgeInsets.all(16.0),
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
child: Consumer<LocationProvider>(
builder: (context, locationProvider, _) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
flex: 20,
child: FutureLoadingBuilder<String>(
future: getAddress(locationProvider.lastIdleLocation),
mutable: true,
loadingIndicator: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
],
child: widget.customLocationCard != null
? Consumer<LocationProvider>(
builder: (context, locationProvider, _) {
return widget.customLocationCard(context, locationProvider);
})
: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
child: Consumer<LocationProvider>(
builder: (context, locationProvider, _) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
flex: 20,
child: FutureLoadingBuilder<String>(
future:
getAddress(locationProvider.lastIdleLocation),
mutable: true,
loadingIndicator: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(),
],
),
builder: (context, address) {
_address = address;
return Text(
address ?? 'Unnamed place',
style: TextStyle(fontSize: 18),
);
}),
),
builder: (context, address) {
_address = address;
return Text(
address ?? 'Unnamed place',
style: TextStyle(fontSize: 18),
);
}),
),
Spacer(),
FloatingActionButton(
onPressed: () {
Navigator.of(context).pop({
'location': LocationResult(
latLng: locationProvider.lastIdleLocation,
address: _address,
)
});
},
child: widget.resultCardConfirmIcon ??
Icon(Icons.arrow_forward),
),
],
Spacer(),
FloatingActionButton(
onPressed: () {
Navigator.of(context).pop({
'location': LocationResult(
latLng: locationProvider.lastIdleLocation,
address: _address,
)
});
},
child: widget.resultCardConfirmIcon ??
Icon(Icons.arrow_forward),
),
],
),
);
}),
),
);
}),
),
),
);
}
Expand Down
Loading