123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:wechat_assets_picker/wechat_assets_picker.dart';
- /*
- * 本地图库的引擎封装,目前用的 wechat_assets_picker 插件
- */
- class AlbumEngine {
- /// 选择图片
- static Future<List<AssetEntity>?> selectImage(
- BuildContext context, {
- int maxAssets = 9,
- List<AssetEntity>? selected,
- int filterMinWidth = 100,
- int filterMaxWidth = 100000,
- int filterMinHeight = 100,
- int filterMaxHeight = 100000,
- }) async {
- FilterOptionGroup filterOptions = FilterOptionGroup()
- ..setOption(
- AssetType.image,
- FilterOption(
- sizeConstraint: SizeConstraint(
- minWidth: filterMinWidth,
- maxWidth: filterMaxWidth,
- minHeight: filterMinHeight,
- maxHeight: filterMaxHeight,
- ),
- ),
- );
- return AssetPicker.pickAssets(
- context,
- pickerConfig: AssetPickerConfig(
- requestType: RequestType.image,
- selectedAssets: selected,
- maxAssets: maxAssets,
- filterOptions: filterOptions,
- gridCount: 4,
- pageSize: 40,
- pickerTheme: ThemeData(
- brightness: Brightness.dark,
- appBarTheme: AppBarTheme(
- systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
- statusBarColor: Colors.transparent,
- statusBarBrightness: Brightness.dark,
- statusBarIconBrightness: Brightness.light,
- ),
- ),
- ),
- ),
- );
- }
- /// 选择视频
- static Future<List<AssetEntity>?> selectVideo(
- BuildContext context, {
- int maxAssets = 1,
- List<AssetEntity>? selected,
- int filterMinWidth = 100,
- int filterMaxWidth = 100000,
- int filterMinHeight = 100,
- int filterMaxHeight = 100000,
- int filterMaxSeconds = 60, //默认能选择60秒以内的视频
- }) async {
- FilterOptionGroup filterOptions = FilterOptionGroup()
- ..setOption(
- AssetType.video,
- FilterOption(
- sizeConstraint: SizeConstraint(
- minWidth: filterMinWidth,
- maxWidth: filterMaxWidth,
- minHeight: filterMinHeight,
- maxHeight: filterMaxHeight,
- ),
- durationConstraint: DurationConstraint(max: Duration(seconds: filterMaxSeconds))),
- );
- return AssetPicker.pickAssets(
- context,
- pickerConfig: AssetPickerConfig(
- requestType: RequestType.video,
- selectedAssets: selected,
- maxAssets: maxAssets,
- filterOptions: filterOptions,
- gridCount: 4,
- pageSize: 40,
- pickerTheme: ThemeData(
- brightness: Brightness.dark,
- appBarTheme: AppBarTheme(
- systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
- statusBarColor: Colors.transparent,
- statusBarBrightness: Brightness.dark,
- statusBarIconBrightness: Brightness.light,
- ),
- ),
- ),
- ),
- );
- }
- }
|