CopyPastor

Detecting plagiarism made easy.

Score: 0.8916380365230215; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2023-02-20
by Flutter Beginner

Original Post

Original - Posted on 2023-02-16
by Flutter Beginner



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I am able to fix this after finding out that the marker didn't got updated because it is in a different state than the main widget, I fix it trough the use of the statebuilder widget. Apparently without statefulbuilder, the setState refresh the whole app but not what the function do. here's the code snip
StatefulBuilder( builder: (context, setMapState) { setMapState( () {}, ); void _whenMapCreated(GoogleMapController controller) async { //debugPrint('>>>>>>>>> onMapCreated'); mapController = controller; _Navmarkers.clear(); _navPolylines.clear(); var direction = await LocationService().getDirectionNoWP(userOrigin, userGoal); _setPolylines(direction['polyline_decoded']); setMapState( () {}, ); } return Column(children: [ Expanded( child: GoogleMap( mapType: MapType.normal, initialCameraPosition: CameraPosition(target: _kGooglePlex, zoom: 11), markers: _Navmarkers, polylines: _navPolylines, onMapCreated: _whenMapCreated, )), Row( children: [ ButtonBar( children: [ IconButton( onPressed: () { Position? userposition; const LocationSettings _locationSettings = LocationSettings( accuracy: LocationAccuracy.high, distanceFilter: 100, ); userStreamlocation = Geolocator.getPositionStream( locationSettings: _locationSettings) .listen((userposition) { _Navmarkers.clear(); _Navmarkers.add(Marker( markerId: MarkerId('User'), position: LatLng(userposition.latitude, userposition.longitude), icon: BitmapDescriptor.defaultMarkerWithHue( BitmapDescriptor.hueRose))); setMapState(() { }); }); }, icon: Icon(Icons.navigation)), IconButton( onPressed: () { setMapState( () { }, ); }, icon: Icon(Icons.refresh)), IconButton( onPressed: () { dispose(); }, icon: Icon(Icons.stop)) ], ) ], ) ]); }, ),
I am able to fix this after finding out that the marker didn't got updated because it is in a different state than the main widget, I fix it trough the use of the statebuilder widget, here's the code snip

StatefulBuilder( builder: (context, setMapState) { setMapState( () {}, ); void _whenMapCreated(GoogleMapController controller) async { //debugPrint('>>>>>>>>> onMapCreated'); mapController = controller; _Navmarkers.clear(); _navPolylines.clear(); var direction = await LocationService().getDirectionNoWP(userOrigin, userGoal); _setPolylines(direction['polyline_decoded']); setMapState( () {}, ); } return Column(children: [ Expanded( child: GoogleMap( mapType: MapType.normal, initialCameraPosition: CameraPosition(target: _kGooglePlex, zoom: 11), markers: _Navmarkers, polylines: _navPolylines, onMapCreated: _whenMapCreated, )), Row( children: [ ButtonBar( children: [ IconButton( onPressed: () { Position? userposition; const LocationSettings _locationSettings = LocationSettings( accuracy: LocationAccuracy.high, distanceFilter: 100, ); userStreamlocation = Geolocator.getPositionStream( locationSettings: _locationSettings) .listen((userposition) { _Navmarkers.clear(); _Navmarkers.add(Marker( markerId: MarkerId('User'), position: LatLng(userposition.latitude, userposition.longitude), icon: BitmapDescriptor.defaultMarkerWithHue( BitmapDescriptor.hueRose))); setMapState(() { }); }); }, icon: Icon(Icons.navigation)), IconButton( onPressed: () { setMapState( () { }, ); }, icon: Icon(Icons.refresh)), IconButton( onPressed: () { dispose(); }, icon: Icon(Icons.stop)) ], ) ], ) ]); }, ),

This way the googlemap have its own state and can be refreshed

        
Present in both answers; Present only in the new answer; Present only in the old answer;