0 purchases
cached map marker
Cached Map Marker #
Provides a Flutter library designed to simplify the process of caching custom markers for Google Maps in Flutter applications. It leverages the flutter_cache_manager package to cache images and widgets, allowing for efficient retrieval and use of custom markers on the map. This package addresses common challenges in managing marker resources by offering functionalities to:
Cache Network Images: Download and cache images from the network, resizing them as needed for use as map markers.
Cache Widgets as Images: Render Flutter widgets to images, cache these images, and use them as custom markers. This is particularly useful for dynamic content that needs to be displayed on the map.
Efficient Resource Management: Provides methods to clear the cache, ensuring that the application manages resources efficiently and avoids unnecessary storage usage.
Features #
Download and Cache: Automatically downloads and caches images for use as map markers, reducing network requests and improving performance.
Custom Marker Size: Allows specifying the size of the marker images, enabling customization according to your application's needs.
Cache Management: Provides a method to clear the cache, helping manage the device's storage and ensuring the latest images are used.
Easy integration: with Google Maps Flutter through BitmapDescriptor objects
Getting Started #
To use the Cached Map Marker package in your Flutter project, follow these steps:
Installation #
Add the following to your pubspec.yaml file:
dependencies:
cached_map_marker: <lastest>
copied to clipboard
Import the package
import 'package:cached_map_marker/cached_map_marker.dart';
copied to clipboard
Creating a Custom Marker from Widget & Network Image, then caching it #
final _cachedMapMarker = CachedMapMarker();
final markers = await Future.wait([
// Create a custom marker from a network image and cache it
_cachedMapMarker.fromNetwork(
url: 'https://cdn-icons-png.flaticon.com/512/5193/5193688.png',
size: const Size(60, 60)),
// Create a custom marker from a widget and cache it
_cachedMapMarker.fromWidget(
widget: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(50),
),
child: const Icon(
Icons.location_on,
color: Colors.red,
size: 50,
),
),
cacheKey: 'widget_marker',
logicalSize: const Size(250, 250),
imageSize: const Size(100, 100),
)
]);
copied to clipboard
Contributing #
Contributions are welcome! Please feel free to submit a pull request.
License #
This package is licensed under the MIT License. See the LICENSE file for details.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.