Skip to content

Commit

Permalink
added mapWidgetKey for _GoogleMapWidget state
Browse files Browse the repository at this point in the history
  • Loading branch information
mtellect committed Mar 14, 2024
1 parent 6c09030 commit 3161c09
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'mirai_google_map.dart';
class MiraiGoogleMapParser extends MiraiParser<MiraiGoogleMap> {
const MiraiGoogleMapParser();

static final mapWidgetKey = GlobalKey();

@override
String get type => WidgetType.googleMap.name;

Expand All @@ -21,7 +23,10 @@ class MiraiGoogleMapParser extends MiraiParser<MiraiGoogleMap> {

@override
Widget parse(BuildContext context, MiraiGoogleMap model) {
return _GoogleMapWidget(model: model);
return _GoogleMapWidget(
key: mapWidgetKey,
model: model,
);
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit 3161c09

Please sign in to comment.