引入包 pasteboard: ^0.3.0final imageBytes = await Pasteboard.image; if (imageBytes == null) { EasyLoading.showError("剪贴板里没有图片数据",duration: Duration(seconds: 5)); return; }
引入包 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'), ),
引入包 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, )
文档地址 https://docs.getwidget.dev/introduction/Github : https://github.com/ionicfirebaseapp/getwidget
默认showModalBottomSheet的宽度,有时候不够用,比如想弹出一个占据全屏宽度的内容.以下是办法:showModalBottomSheet( context: context, constraints: BoxConstraints( maxWidth: 600, //设置约束 ), builder: ... ),