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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
pubspec.lock
70 changes: 64 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,69 @@ to display the previously selected location.
void showPlacePicker() async {
LocationResult result = await Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
PlacePicker("YOUR API KEY",
displayLocation: customLocation,
)));

// Handle the result in your way
print(result);
PlacePicker(
"YOUR_API_KEY",
displayLocation: LatLng(33.2, 66.4),
localizationItem: LocalizationItem(languageCode: "fa_IR"),
searchBarOptions: SearchBarOptions(
padding: EdgeInsets.zero,
backgroundColor: Colors.white,
elevation: 2,
overlyTopPadding:
MediaQuery.of(context).padding.top + kToolbarHeight,
searchIcon: Icon(
Feather.search,
color: Colors.red,
),
clearTextIcon: Icon(
AntDesign.close,
color: Colors.red,
),
inputDecoration: InputDecoration(
hintText: "Search Place",
border: InputBorder.none,
hintStyle: TextStyle(),
),
// height: 50,
searchIconPadding:
EdgeInsets.symmetric(horizontal: 16, vertical: 4),
clearTextIconPadding:
EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
// color: Colors.white,
),
),
//searchAutoCompletLoadingBuilder: () => Material(
// child: SizedBox(
// height: 50,
// width: 50,
// child: Center(child: CircularProgressIndicator()),
// ),
//),
//bottomResultWidgetBuilder: (_, __, ___, h, _____) => SizedBox(
// height: h / 4,
//),
//searchAutoCompleteItemBuilder: (a, b) => GestureDetector(
// onTap: b,
//child: Text(
// a.text,
// ),
//),
//searchAutoCompleteBuilder: (list) => Material(
// elevation: 1,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: list,
// ),
//),
mapOptions: MapOptions(
myLocationButtonEnabled: true,
),
),
),
);

// Handle the result in your way
print(result);
}
```
29 changes: 29 additions & 0 deletions lib/entities/map_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:google_maps_flutter/google_maps_flutter.dart';

class MapOptions {
///this will override the displyLocation of google maps.
final CameraPosition? initialCameraPosition;
final bool? compassEnabled;
final bool? mapToolbarEnabled;
final bool? scrollGestureEnabled;
final bool? myLocationEnabled;
final bool? myLocationButtonEnabled;
final bool? zoomControllEnabled;
final bool? zoomGestureEnabled;
final bool? rotateGestureEnabled;
final BitmapDescriptor? markerIcon;
final MapType? mapType;
MapOptions({
this.initialCameraPosition,
this.compassEnabled,
this.mapToolbarEnabled,
this.scrollGestureEnabled,
this.myLocationEnabled,
this.myLocationButtonEnabled,
this.zoomControllEnabled,
this.markerIcon,
this.mapType,
this.rotateGestureEnabled,
this.zoomGestureEnabled,
});
}
53 changes: 53 additions & 0 deletions lib/entities/search_bar_options_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

class SearchBarOptions {
///To Wrap search bar with padding
final EdgeInsetsGeometry? padding;

///Search icon padding
final EdgeInsetsGeometry? searchIconPadding;

///clear Text button icon padding
final EdgeInsetsGeometry? clearTextIconPadding;

///A background color to set if the search bar hasPadding
final Color? backgroundColor;

///elavtion of Searchbar in case for example you add a transparetnt background color to searchbar
final double? elevation;

///This is used to add extra space on top of autosuggestion.
///This is usefull for example when you use PlacePicker inside another Scaffold which has appbar
///
///Simple Usage: `overlyTopPadding: MediaQuery.of(context).padding.top + kToolbarHeight,`
final double? overlyTopPadding;

///Search Bar height,
final double? height;

///Icon for SearchBar
final Widget? searchIcon;

///Icon for clear text button
final Widget? clearTextIcon;

///Decoration to apply to search input
final InputDecoration? inputDecoration;

///Decoration for searchbar
final Decoration? decoration;

const SearchBarOptions({
this.padding,
this.backgroundColor,
this.elevation,
this.clearTextIcon,
this.overlyTopPadding,
this.searchIcon,
this.inputDecoration,
this.searchIconPadding,
this.decoration,
this.height,
this.clearTextIconPadding,
});
}
3 changes: 3 additions & 0 deletions lib/place_picker.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export 'widgets/widgets.dart';
export 'entities/entities.dart';
export 'package:google_maps_flutter/google_maps_flutter.dart' show LatLng;
export 'entities/search_bar_options_model.dart';
export 'entities/map_options.dart';
export 'package:google_maps_flutter/google_maps_flutter.dart';
Loading