Hwj's blog - 2025年1月
type: channel
link: https://blog.hwj.im/index.php/2025/01/
items: Flutter web 中,从剪贴板里读取图片
items: Flutter web 中拖拉文件
items: 在Flutter Web 显示本地图像
items: Flutter 组件推荐: GetWidget
items: Flutter控制showModalBottomSheet的宽度

Flutter web 中,从剪贴板里读取图片
type: item
date: 2025-01-23T00:25:55+08:00
description: 引入包 pasteboard: ^0.3.0final imageBytes = await Pasteboard.image; if (imageBytes == null) { EasyLoading.showError("剪贴板里没有图片数据",duration: Duration(seconds: 5)); return; }

Flutter web 中拖拉文件
type: item
date: 2025-01-23T00:24:36+08:00
description: 引入包 flutter_dropzone: ^4.2.1DropzoneView( operation: DragOperation.copy, cursor: CursorType.grab, onCreated: (ctrl) => controller1 = ctrl, onLoaded: () => print('Zone 1 loaded'), onError: (error) => print('Zone 1 error: $error'), onHover: () { // setState(() => highlighted1 = true); print('Zone 1 hovered'); }, onLeave: () { // setState(() => highlighted1 = false); print('Zone 1 left'); }, onDropFile: (file) async { print('Zone 1 drop: ${file.name}'); setState(() { // message1 = '${file.name} dropped'; // highlighted1 = false; }); final bytes = await controller1.getFileData(file); print('Read bytes with length ${bytes.length}'); // 读取到了文件内容 setState(() { images.add(bytes); }); // print(bytes.sublist(0, min(bytes.length, 20))); }, onDropString: (s) { print('Zone 1 drop: $s'); setState(() { // message1 = 'text dropped'; // highlighted1 = false; }); //print(s.substring(0, min(s.length, 20))); }, onDropInvalid: (mime) => print('Zone 1 invalid MIME: $mime'), onDropFiles: (files) => print('Zone 1 drop multiple: $files'), onDropStrings: (strings) => print('Zone 1 drop multiple: $strings'), ),

在Flutter Web 显示本地图像
type: item
date: 2025-01-23T00:05:54+08:00
description: 引入包 image_picker_web: ^4.0.0 extended_image: ^9.1.0 // 选择本地多个文件 List<Uint8List>? items = await ImagePickerWeb.getMultiImagesAsBytes(); //显示图片 ExtendedImage( image: MemoryImage(imageData), width: 200, fit: BoxFit.cover, )

Flutter 组件推荐: GetWidget
type: item
date: 2025-01-21T20:16:37+08:00
description: 文档地址 https://docs.getwidget.dev/introduction/Github : https://github.com/ionicfirebaseapp/getwidget

Flutter控制showModalBottomSheet的宽度
type: item
date: 2025-01-21T20:05:11+08:00
description: 默认showModalBottomSheet的宽度,有时候不够用,比如想弹出一个占据全屏宽度的内容.以下是办法:showModalBottomSheet( context: context, constraints: BoxConstraints( maxWidth: 600, //设置约束 ), builder: ... ),