aes_assets_widget 0.0.4 copy "aes_assets_widget: ^0.0.4" to clipboard
aes_assets_widget: ^0.0.4 copied to clipboard

A new Flutter plugin.

aes_assets_widget plugin for Flutter #

Getting Started #

A Flutter plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera. Support to preview photos and scale photos in full-screen

Android iOS
Support SDK 21+ iOS 9+

Features #

  • 支持图片、视频选择,支持拍照、拍视频
  • iOS支持图库多图片选择,安卓支持单图上传,都支持超上传上限提示
  • 支持图片、视频资源预览
  • 自带通用展示图片样式
  • 支持删除

TODO #

  • 支持svg
  • 增加其他UI样式

Dependencies(依赖的外部插件) #

image_picker: ^0.8.5+3 photo_view: ^0.14.0 dio: ^4.0.6

Installation #

aes_assets_widget:^0.0.1

iOS #

This plugin requires iOS 9.0 or higher.

Starting with version 0.8.1 the iOS implementation uses PHPicker to pick (multiple) images on iOS 14 or higher. As a result of implementing PHPicker it becomes impossible to pick HEIC images on the iOS simulator in iOS 14+. This is a known issue. Please test this on a real device, or test with non-HEIC images until Apple solves this issue. 63426347 - Apple known issue

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSCameraUsageDescription - describe why your app needs access to the camera. This is called _ Privacy - Camera Usage Description_ in the visual editor.
  • NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.

Android #

Starting with version 0.8.1 the Android implementation support to pick (multiple) images on Android 4.3 or higher.

No configuration required - the plugin should work out of the box. It is however highly recommended to prepare for Android killing the application when low on memory. How to prepare for this is discussed in the Handling MainActivity destruction on Android section.

It is no longer required to add android:requestLegacyExternalStorage="true" as an attribute to the <application> tag in AndroidManifest.xml, as image_picker has been updated to make use of scoped storage.

Note: Images and videos picked using the camera are saved to your application's local cache, and should therefore be expected to only be around temporarily. If you require your picked image to be stored permanently, it is your responsibility to move it to a more permanent location.

Example #

import 'package:aes_assets_widget/aes_assets_widget.dart';

    ...
            late AesAssetsWidget _aesAssetsWidget;
            _aesAssetsWidget = AesAssetsWidget(
            dataList: [],
            title: '燃气表照片:',
            );
            然后在加载到位置
    ...

如果需要上传图片,目前有两种方法

方法一:自行在插件外部上传:

      ...
           AESResultData result =
                 await UploaderUtil.upload(files: _aesAssetsWidget.dataList);
      ...

方法二:插件内部自动上传,你需要做的是:

      ...
           AesAssetsWidget(
            dataList: [],
            title: '图片资源',
            uploadPath:
                'http://10.0.0.125:10086/smart-admin-api/api/file/localUpload',
            authToken: const {
              'x-access-token':
                  "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1ODY2M2JmNi0zNzllLTQ0ZWEtYWI1My02NTQ5MjJjMDRiYzYiLCJpZCI6MSwibmJmIjoxNjU5NDkzMzc1LCJleHAiOjE2NjAwOTgxNzV9.FJB1gxjENQI2aY9qgEWdCZXg9A2aRvfvjDX7iavXefu9luTZEK4z4NzeBIq9qv2yy4cT5CRb4EKi0zacHHhg-Q"
            },
          )
      ...

uploadPath:是你的图片上传地址,跟后台要即可, #

authToken:是你的鉴权token,问后台时候需要这个字段,不需要可不填 #

后台接口约定:multipart/formdata类型;如果需要token鉴权,需要放到header里,字段为x-access-token;当然你也可以修改插件代码,跟后台上台商量重新定制上传接口规则,比如增加query参数 #

总结 #

遇到最大的问题就是在Plugin中引用图片,一直加载失败困扰好几天。。。。,原因就是找不到路径,不过已经解决,可以参考插件代码和yaml资源路径配置,请严格按照配置语法来, 关键代码如下:

   ...
        const Image(
        image: AssetImage('assets/images/fix_add_image.png',
        package: 'aes_assets_widget'),
   ...

)





1
likes
55
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Homepage

Documentation

API reference

License

Apache-2.0, BSD-3-Clause (license)

Dependencies

dio, flutter, image_picker, photo_view

More

Packages that depend on aes_assets_widget