flutter_widget_to_marker_one 0.0.1
flutter_widget_to_marker_one: ^0.0.1 copied to clipboard
A Flutter package that converts Flutter widgets into Google Maps markers, allowing for custom, dynamic marker designs using standard Flutter widgets.
Flutter Widget to Marker #
A Flutter package that converts any Flutter widget into a Google Maps marker icon. This package makes it easy to create custom, dynamic marker designs using standard Flutter widgets.
[Example Marker]
Features #
- Convert any Flutter widget to a Google Maps marker
- Customize marker size and pixel ratio
- Support for all Flutter widgets including containers, text, images, and custom designs
- Easy to use API
Getting started #
Add this package to your Flutter project by including it in your pubspec.yaml:
dependencies:
flutter_widget_to_marker_one: ^0.0.1
Usage #
Here's a simple example of how to use the package:
import 'package:flutter_widget_to_marker_one/flutter_widget_to_marker_one.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
// Create a custom marker from a widget
BitmapDescriptor customMarker = await convertWidgetToBitmapDescriptor(
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5,
),
],
),
child: Text('Custom Marker'),
),
context: context,
size: Size(150, 80),
);
// Use the custom marker in Google Maps
Marker(
markerId: MarkerId('custom_marker'),
position: LatLng(37.7749, -122.4194),
icon: customMarker,
)
Advanced Usage #
You can create more complex markers using any Flutter widget:
BitmapDescriptor customMarker = await convertWidgetToBitmapDescriptor(
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.location_on, color: Colors.white),
Text(
'Custom\nMarker',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
],
),
),
context: context,
size: Size(120, 120),
pixelRatio: 2.0,
);
Additional information #
- The package requires a
BuildContextto function properly - Higher pixel ratios will result in sharper images but larger file sizes
- The conversion process is asynchronous, so make sure to await the result
- For best results, test your markers at different zoom levels
For issues, feature requests, or contributions, please visit our GitHub repository.