File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,8 @@ class ChartPainter extends CustomPainter {
235235 canvas.save ();
236236 final pos = params.tapPosition! ;
237237 final fingerSize = 32.0 ; // leave some margin around user's finger
238- var dx, dy;
238+ double dx, dy;
239+ assert (params.size.width >= panelWidth, "Overlay panel is too wide." );
239240 if (pos.dx <= params.size.width / 2 ) {
240241 // If user touches the left-half of the screen,
241242 // we show the overlay panel near finger touch position, on the right.
@@ -244,6 +245,7 @@ class ChartPainter extends CustomPainter {
244245 // Otherwise we show panel on the left of the finger touch position.
245246 dx = pos.dx - panelWidth - fingerSize;
246247 }
248+ dx = dx.clamp (0 , params.size.width - panelWidth);
247249 dy = pos.dy - panelHeight - fingerSize;
248250 if (dy < 0 ) dy = 0.0 ;
249251 canvas.translate (dx, dy);
You can’t perform that action at this time.
0 commit comments