You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the map is inside a scaling widget, such as Transform.scale(... child: FlutterMap(...)) the onTap gestures are not scaled correctly, leading to both the onTap(TapPosition tapPosition, LatLng point) being slightly the wrong place, even though the map looks correct.
testWidgets('Test tap is detected where expected with scale and offset.',
(tester) async {
const screenSize =Size(400, 400);
await tester.binding.setSurfaceSize(screenSize);
Offset? lastTap;
// The Transform.scale fills the screen, but the PositionedTapDetector2// occupies the center, with height of 200 (0.5 * 400) and width 400.final widget =Transform.scale(
scaleY:0.5,
child:PositionedTapDetector2(
onTap: (position) => lastTap = position.relative,
child:SizedBox(
width: screenSize.width,
height: screenSize.height,
child:Container(
color:Colors.red,
),
),
),
);
await tester.pumpWidget(widget);
// On the screen the PositionedTapDetector2 is actually 400x200, but the// widget thinks its 400x400.expect(screenSize, tester.getSize(find.byType(SizedBox)));
Future<void> tap(Offset pos, Offset expected) async {
lastTap =null;
await tester.tapAt(pos);
expect(lastTap, expected);
}
// Tap top left of PositionedTapDetector2 which should be 0,0.awaittap(constOffset(0, 100), Offset.zero);
// Tap bottom right of PositionedTapDetector2awaittap(constOffset(400-1, 300-0.5),
Offset(screenSize.width -1, screenSize.height -1));
});
Obtrusive: Prevents normal functioning but causes no errors in the console
The text was updated successfully, but these errors were encountered:
bramp
added
bug
This issue reports broken functionality or another error
needs triage
This new bug report needs reproducing and prioritizing
labels
Oct 2, 2023
What is the bug?
When the map is inside a scaling widget, such as
Transform.scale(... child: FlutterMap(...))
the onTap gestures are not scaled correctly, leading to both the onTap(TapPosition tapPosition, LatLng point) being slightly the wrong place, even though the map looks correct.This seems to be due to PositionedTapDetector2._getTapPositions translating the global coordinates to local coordinates, but not correctly scaling them.
How can we reproduce it?
Do you have a potential solution?
Yes, #1676
Platforms
Tested on Chrome (Web) and Android.
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console
The text was updated successfully, but these errors were encountered: