flutter_w3w_map 1.0.0
flutter_w3w_map: ^1.0.0 copied to clipboard
A Flutter package that integrates What3Words with Google Maps, allowing for easy 3-word address conversions and grid rendering.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:w3w_google_maps/w3w_google_maps.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'W3W Google Maps Example',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const ExampleScreen(),
);
}
}
class ExampleScreen extends StatelessWidget {
const ExampleScreen({super.key});
@override
Widget build(BuildContext context) {
// Provide your W3W API key here
const String w3wApiKey = "YOUR_WHAT3WORDS_API_KEY";
return W3WGoogleMaps.provider(
w3wApiKey: w3wApiKey,
child: Scaffold(
appBar: AppBar(
title: const Text('W3W Google Maps Demo'),
),
body: W3WGoogleMap(
initialCameraPosition: const CameraPosition(
target: LatLng(23.0225, 72.5714),
zoom: 12,
),
onW3WSelected: (w3w) {
debugPrint('Selected What3Words address: ///${w3w.words}');
},
markers: {
const Marker(
markerId: MarkerId('initial_location'),
position: LatLng(23.0225, 72.5714),
infoWindow: InfoWindow(
title: 'Starting Point',
snippet: 'Ahmedabad, India',
),
),
},
),
),
);
}
}