<p>To move a container to a different location on touch, you can use the Positioned widget in combination with the GestureDetector widget.</p> <p>Here is the sample output of this app.</p> <p>);</p> <p id="9cdcfe;](key" color:="" color:=>color: #569cd6;](class color: #4ec9b0;](MyApp color: #569cd6;](extends color: #4ec9b0;](StatelessWidget ); color: #9cdcfe;](@ color: #9cdcfe;](override</p> <p>color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext color: #9cdcfe;](context) { color: #c586c0;](return color: #4ec9b0;](MaterialApp( color: #9cdcfe;](home: color: #4ec9b0;](Scaffold( color: #9cdcfe;](appBar: color: #4ec9b0;](AppBar( color: #9cdcfe;](title: color: #569cd6;](const color: #4ec9b0;](Text(color: #ce9178;]('Move Container on Touch App'), ), color: #9cdcfe;](body: color: #569cd6;](const color: #4ec9b0;](TouchMoveExample(), ), ); } }</p> <p id="9cdcfe;](key" color:= color:="">color: #569cd6;](class color: #4ec9b0;](TouchMoveExample color: #569cd6;](extends color: #4ec9b0;](StatefulWidget ); color: #9cdcfe;](@ color: #9cdcfe;](override</p> <p>color: #4ec9b0;](State color: #dcdcaa;](createState() => color: #4ec9b0;](_TouchMoveExampleState(); }</p> <p>color: #569cd6;](class color: #4ec9b0;](_TouchMoveExampleState color: #569cd6;](extends color: #4ec9b0;](State { color: #4ec9b0;](double color: #9cdcfe;](_xPosition = color: #b5cea8;](0; color: #4ec9b0;](double color: #9cdcfe;](_yPosition = color: #b5cea8;](0; color: #9cdcfe;](@ color: #9cdcfe;](override</p> <p>color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext color: #9cdcfe;](context) { color: #c586c0;](return color: #4ec9b0;](Stack( color: #9cdcfe;](children: [ color: #4ec9b0;](Positioned( color: #9cdcfe;](left: color: #9cdcfe;](_xPosition, color: #9cdcfe;](top: color: #9cdcfe;](_yPosition, color: #9cdcfe;](child: color: #4ec9b0;](GestureDetector( color: #9cdcfe;](onPanUpdate: (color: #9cdcfe;](details) { color: #dcdcaa;](setState(() { color: #9cdcfe;](_xPosition += color: #9cdcfe;](details.color: #9cdcfe;](delta.color: #9cdcfe;](dx; color: #9cdcfe;](_yPosition += color: #9cdcfe;](details.color: #9cdcfe;](delta.color: #9cdcfe;](dy; }); }, color: #9cdcfe;](child: color: #4ec9b0;](Container( color: #9cdcfe;](width: color: #b5cea8;](100, color: #9cdcfe;](height: color: #b5cea8;](100, color: #9cdcfe;](color: color: #4ec9b0;](Colors.color: #9cdcfe;](red, ), ), ), ], ); } } ` Thanks,Srikanth</p>
Move container to a different location on touch in flutter
This Article is posted by seven.srikanth at 1/2/2023 5:21:27 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: drag and drop; move on touch;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter