我正在尝试使用 SingleChildScrollView 制作可滚动和可缩放的堆栈,以实现画布编辑器。
当我将可拖动项目放入初始视图中时,拖放效果非常好,但是当我向下滚动视图并尝试放下容器时,拖放会返回到初始视图中。
我是 Flutter 开发的新手,所以也许我在实现这样的事情时误解了。
这是我目前拥有的代码。
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: App(),
),
);
}
}
class App extends StatefulWidget {
@override
AppState createState() => AppState();
}
class AppState extends State<App> {
Color caughtColor = Colors.grey;
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Stack(
children: <Widget>[
Container(
height: 2000,
),
DragBox(Offset(0.0, 0.0), 'Box One', Colors.blueAccent),
],
),
);
}
}
class DragBox …Run Code Online (Sandbox Code Playgroud)