上效果
预期的是通过拖动一条边界线改变窗口大小,类似vscode里拖动效果。这个是简单的拖动实现
上代码:
import 'package:flutter/material.dart';class MyDraggableViewDemo extends StatelessWidget {const MyDraggableViewDemo({super.key});Widget build(BuildContext context) {return MaterialApp(home: Scaffold(appBar: AppBar(title: Text('MyDraggableViewDemo'),),body: DraggableDemo(),),);}
}class DraggableDemo extends StatefulWidget {const DraggableDemo({super.key});State<StatefulWidget> createState() {return _DraggableDemoState();}
}class _DraggableDemoState extends State<DraggableDemo> {double width = 200.0;double height = 200.0;Widget build(BuildContext context) {return Center(child: GestureDetector(onPanUpdate: (details) {setState(() {width = width + details.delta.dx;height = height + details.delta.dy;});},child: Container(width: width,height: height,color: Colors.blue,child: Center(child: Text('点击 拖动后改变窗口大小',style: TextStyle(color: Colors.white),),),),),);}
}
所以预期的边界线效果,应该是对边界线进行处理,然后和关联的 widget 进行联动,
下一篇见
======End