flutter_location_search 1.2.0 flutter_location_search: ^1.2.0 copied to clipboard
Package that provides Place search with history of latest location searched using Open Street Map. It is easy to custom and can be displayed in fullscreen or overlay mode
import 'package:flutter/material.dart';
import 'package:flutter_location_search/flutter_location_search.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _locationText = 'Tap here to search a place';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Location Picker',
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Builder(builder: (context) {
return TextButton(
child: Text(_locationText),
onPressed: () async {
LocationData? locationData = await LocationSearch.show(
context: context,
lightAddress: true,
mode: Mode.overlay,
);
if (locationData == null) return;
_locationText = locationData.address;
setState(() {});
},
);
}),
),
),
);
}
}