From 3161c0941dfb37da0987d3deb3afaeb62df7744b Mon Sep 17 00:00:00 2001 From: Maugost Date: Thu, 14 Mar 2024 08:47:28 +0100 Subject: [PATCH] added mapWidgetKey for _GoogleMapWidget state --- .../mirai_google_map_parser.dart | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/mirai/lib/src/parsers/mirai_google_map/mirai_google_map_parser.dart b/packages/mirai/lib/src/parsers/mirai_google_map/mirai_google_map_parser.dart index 74541b30..90d09a45 100644 --- a/packages/mirai/lib/src/parsers/mirai_google_map/mirai_google_map_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_google_map/mirai_google_map_parser.dart @@ -13,6 +13,8 @@ import 'mirai_google_map.dart'; class MiraiGoogleMapParser extends MiraiParser { const MiraiGoogleMapParser(); + static final mapWidgetKey = GlobalKey(); + @override String get type => WidgetType.googleMap.name; @@ -21,7 +23,10 @@ class MiraiGoogleMapParser extends MiraiParser { @override Widget parse(BuildContext context, MiraiGoogleMap model) { - return _GoogleMapWidget(model: model); + return _GoogleMapWidget( + key: mapWidgetKey, + model: model, + ); } } @@ -36,6 +41,20 @@ class _GoogleMapWidget extends StatefulWidget { class __GoogleMapWidgetState extends State<_GoogleMapWidget> { GoogleMapController? _googleMapController; + late MiraiGoogleMap model = widget.model; + + @override + void initState() { + super.initState(); + } + +@override + void didUpdateWidget(covariant _GoogleMapWidget oldWidget) { + super.didUpdateWidget(oldWidget); + if(widget.model != model){ + setState(() => model = widget.model); + } + } @override Widget build(BuildContext context) {