-
-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Bug
Whenever a rebuild is triggered while dragging a DragMarker it returns to its initial position. The example below shows two such dragMarkers. Although the position of Marker1 (black) should change on dragging, rebuilding the widget causes it to always return to its initial position. Maker2 (red) on the other hand is continuously updated on Drag update which allows for it to be moved around, but when it is dragged outside the border of the map it sometimes gets stuck even though its still being dragged.
flutter_drag_marker_bug.mov
Expected Output:
A rebuild should not cause any change in the position of a Drag Marker while it is being dragged.
Reproducing the Bug:
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_dragmarker/dragmarker.dart';
import 'package:latlong2/latlong.dart';
void main() {
runApp(const DragMarkerTest());
}
class DragMarkerTest extends StatefulWidget {
const DragMarkerTest({Key? key}) : super(key: key);
@override
DragMarkerTestState createState() => DragMarkerTestState();
}
class DragMarkerTestState extends State<DragMarkerTest> {
LatLng _marker1Position = LatLng(44.1461, 9.6400);
LatLng _marker2Position = LatLng(44.1461, 9.6412);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
floatingActionButton: Text(' Marker1 Position : $_marker1Position \n Marker2 Position : $_marker2Position'),
body: FlutterMap(
options: MapOptions(
allowPanningOnScrollingParent: false,
plugins: [
DragMarkerPlugin(),
],
center: _marker1Position,
zoom: 18,
),
layers: [
TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
DragMarkerPluginOptions(
markers: [
DragMarker(
point: LatLng(44.1461, 9.6400),
width: 80.0,
height: 80.0,
offset: const Offset(0.0, -8.0),
builder: (ctx) =>
const Icon(Icons.location_on, size: 50),
feedbackBuilder: (ctx) =>
const Icon(Icons.edit_location, size: 50),
feedbackOffset: const Offset(0.0, -8.0),
onDragUpdate: (details, point) {
setState(() {
_marker1Position = point;
});
},
),
DragMarker(
point: _marker2Position,
width: 80.0,
height: 80.0,
offset: const Offset(0.0, -8.0),
builder: (ctx) =>
const Icon(Icons.location_on, size: 50, color : Colors.red),
feedbackBuilder: (ctx) =>
const Icon(Icons.edit_location, size: 50, color: Colors.red),
feedbackOffset: const Offset(0.0, -8.0),
onDragUpdate: (details, point) {
setState(() {
_marker2Position = point;
});
},
)
],
),
],
),
),
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels