Skip to content

Commit

Permalink
created _GoogleMapWidget to hold Map state
Browse files Browse the repository at this point in the history
  • Loading branch information
mtellect committed Mar 14, 2024
1 parent 2f4a005 commit 6c09030
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import 'mirai_google_map.dart';
class MiraiGoogleMapParser extends MiraiParser<MiraiGoogleMap> {
const MiraiGoogleMapParser();

// final Completer<GoogleMapController> _completer = Completer();

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

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

@override
Widget parse(BuildContext context, MiraiGoogleMap model) {

return _GoogleMapWidget(model: model);
}
}

class _GoogleMapWidget extends StatefulWidget {
const _GoogleMapWidget({super.key, required this.model});

final MiraiGoogleMap model;

@override
State<_GoogleMapWidget> createState() => __GoogleMapWidgetState();
}

class __GoogleMapWidgetState extends State<_GoogleMapWidget> {
GoogleMapController? _googleMapController;

@override
Widget build(BuildContext context) {
final model = widget.model;
return GoogleMap(
initialCameraPosition: model.initialCameraPosition.parse,
style: model.style,
Expand Down Expand Up @@ -83,7 +99,7 @@ class MiraiGoogleMapParser extends MiraiParser<MiraiGoogleMap> {
onLongPress: model.onLongPress == null ? null : (_) => model.onLongPress,
onTap: model.onTap == null ? null : (_) => model.onTap,
onMapCreated: (controller) {
// return _completer.complete(controller);
_googleMapController = controller;
},
cloudMapId: model.cloudMapId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ class MiraiTabBarView with _$MiraiTabBarView {
@Default(Clip.hardEdge) Clip clipBehavior,
}) = _MiraiTabBarView;

factory MiraiTabBarView.fromJson(Map<String, dynamic> json) =>
_$MiraiTabBarViewFromJson(json);
factory MiraiTabBarView.fromJson(Map<String, dynamic> json) => _$MiraiTabBarViewFromJson(json);
}

0 comments on commit 6c09030

Please sign in to comment.