当前位置: 首页 > news >正文

【FlutterDart】 拖动改变 widget 的窗口尺寸大小GestureDetector~简单实现(10 /100)

上效果

在这里插入图片描述
预期的是通过拖动一条边界线改变窗口大小,类似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

http://www.lryc.cn/news/516037.html

相关文章:

  • 【论文笔记】LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models
  • 数据挖掘——朴素贝叶斯分类
  • unity中的UI系统---GUI
  • 鸿蒙Flutter实战:15-Flutter引擎Impeller鸿蒙化、性能优化与未来
  • C语言冒泡排序教程简介
  • Fabric链码部署测试
  • k620老显卡,装cuda.等。
  • 网站常用功能模块-鉴权
  • 直接插入排序、折半插入排序、2路插入排序、希尔排序
  • FQ-GAN代码解析
  • 如何恢复已删除的 Telegram 消息 [iOSamp;Android]
  • asp.net core中的 Cookie 和 Session
  • Python实现一个简单的 HTTP echo 服务器
  • Ruby 中文编码
  • 淘金优化算法的信息共享与更新机制改进
  • Python中的ast.literal_eval:安全地解析字符串为Python对象
  • 【AI数学基础】线性代数:内积和范数
  • Go语言的 的泛型(Generics)核心知识
  • C++vector
  • 如何配置【Docker镜像】加速器+【Docker镜像】的使用
  • Docker--Docker Network(网络)
  • Vue项目中生成node_modules文件夹的两种常用方法及npm优势
  • 如何在 Ubuntu 22.04 上安装 Cassandra NoSQL 数据库教程
  • leetcode 面试经典 150 题:轮转数组
  • 如何在 Mac 上轻松恢复语音备忘录
  • C++ 基础概念: 未定义行为(Undefined Behavior)
  • Rad Studio 11.3 Alexandria 3236a(DELPHI 11.3)官方ISO/百度云盘 下载地址
  • vue3-watchEffect异步依赖收集
  • 微信小程序中 “页面” 和 “非页面” 的区别
  • 【蓝桥杯】43709.机器人繁殖