flutter图片相关
# flutter图片相关
# 1 加载
- 常规加载
- 大图查看和手势缩放
- 缓存处理
推荐: https://github.com/fluttercandies/extended_image
强大的官方 Image 扩展组件, 支持加载以及失败显示,缓存网络图片,缩放拖拽图片,图片浏览(微信掘金效果),滑动退出页面(微信掘金效果),编辑图片(裁剪旋转翻转),保存,绘制自定义效果等功能
https://pub.dev/packages/cached_network_image
Android ScaleType and BoxFit should match like this:
- CENTER = none
- CENTER_CROP = cover
- CENTER_INSIDE = scaleDown
- FIT_CENTER = contain (alignment.center)
- FIT_END = contain (alignment.bottomright)
- FIT_START = contain (alignment.topleft)
- FIT_XY = fill
Ex :-
Image.asset('assets/images/your_image.png',fit: BoxFit.fill)
So you should use Cover to achieve the CENTER_CROP result.
EDIT:
The problem should be crossAxisAlignment
of the Column widget. Setting this property to crossAxisAlignment: CrossAxisAlignment.stretch
should fix your issue.
# flutter imageview 设置match_parent
ExtendedImage.file(File(element.localPath),
fit: BoxFit.cover,
alignment: Alignment.topLeft,
width: double.infinity,
height: double.infinity,);
2
3
4
5
# 2 压缩
https://github.com/fluttercandies/flutter_image_compress
# 3 exif操作
# 4 拍照
https://github.com/fluttercandies/flutter_wechat_camera_picker
https://pub.dev/packages/camera Display live camera preview in a widget. Snapshots can be captured and saved to a file. Record video.Add access to the image stream from Dart.
# 5 选图/选文件
https://github.com/fluttercandies/flutter_wechat_assets_picker
https://pub.dev/packages/image_picker A Flutter plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera.
# 6 保存图片到相册
https://juejin.cn/post/7086762420626014222 预览大图并保存到相册的库和使用demo代码
# 7 纯dart
https://github.com/brendan-duncan/image 图片相关操作, load, save and manipulate images in a variety of different file formats