搜尋套件、儲存庫與 APP 分類

widget_to_marker 封面
套件詳情v1.0.6

widget_to_marker

一個將任何 Flutter Widget 轉換為 BitmapDescriptor 的套件,可用於 google_maps_flutter 圖標標記。

AndroidiOSWeb
近 30 天下載
1.7萬
喜歡數
133
Pub 分數
155

安裝套件

flutter pub add widget_to_marker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

widget_to_marker 套件讓開發者能夠將任何 Flutter 小工具轉換為 BitmapDescriptor,進而透過 google_maps_flutter 插件將自訂設計的小工具用作 Google 地圖標記上的圖示。這對於建立視覺豐富、動態的標記特別有用,這些標記超越了標準圖示。此套件支援 Android、iOS 和 Web 平台,確保跨平台的一致性。它簡化了在地圖上直接渲染複雜 UI 元素(如頭像、徽章或自訂形狀)的過程。

適用情境

  • 帶有動態內容的自定義地圖標記
  • 在地圖上顯示用戶頭像
  • 建立品牌或主題標記
  • 即時標記更新與動畫小部件
  • 在地圖上疊加互動式使用者介面元素

主要特色

  • 將任何 Flutter widget 轉換為 BitmapDescriptor
  • 支援 Android、iOS 與 Web
  • 與 google_maps_flutter 的簡單整合
  • 複雜組件的高效渲染
  • 跨平台相容性

適合對象

  • 開發互動地圖的開發者
  • 需要品牌化或個性化標記的應用程式
  • 使用動態或動畫標記內容的專案
  • 優先考慮跨平台的視覺一致性
  • 尋找靜態圖標圖像替代方案的使用者

使用建議

  • 複雜或頻繁更新的組件對效能的影響
  • 位圖生成可能帶來的記憶體開銷
  • 需要妥善處理產生的描述符
  • 僅限靜態快照(非互動式小部件)
  • 可能需要針對高頻率更新進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Features

When using Google Maps, we always have a problem with adding a marker on the map, and the available tools were either drawing the marker through canvas path or using an image, but the problem is if we want to add words or data or add custom edit to this marker, but this package has solved the problem and now you can use any widget in flutter as a marker for google map ! using the .toBitmapDescriptor() function on the widget to use it as a marker icon!

Getting started

Add dependency

dependencies:
  widget_to_marker: ^1.0.6

1 - Create Your Widget To Make it as Marker:

import 'package:widget_to_marker/widget_to_marker.dart';

class TextOnImage extends StatelessWidget {
  const TextOnImage({
    super.key,
    required this.text,
  });
  final String text;
  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        Image(
          image: const AssetImage(
            "assets/marker.png",
          ),
          height: 150,
          width: 150,
        ),
        Text(
          text,
          style: TextStyle(color: Colors.black),
        )
      ],
    );
  }
}

2 - Add it to the marker with .toBitmapDescriptor():

Marker(
      markerId: const MarkerId("3"),
      position: const LatLng(30.01124477440843, 30.78459296375513),
      icon: await TextOnImage(
        text: "Hello World",
      ).toBitmapDescriptor(
         logicalSize: const Size(150, 150), imageSize: const Size(150, 150)
      ),
    )

Note

You Can Use waitToRender Attribute to set duration for rendering large network and asset images

Enjoy!!

image

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。