Skip to content

Commit 87e913b

Browse files
committed
🐛 Fix arguments judging condition with preview thumb size.
Resolves #60 .
1 parent c611625 commit 87e913b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/src/constants/constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Constants {
2727
static AssetsPickerTextDelegate textDelegate =
2828
DefaultAssetsPickerTextDelegate();
2929
static SortPathDelegate sortPathDelegate = SortPathDelegate.common;
30+
31+
static const List<int> defaultPreviewThumbSize = <int>[200, 200];
3032
}
3133

3234
/// Log only in debug mode.

lib/src/provider/asset_entity_image_provider.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ import 'dart:ui' as ui;
88
import 'package:flutter/material.dart';
99
import 'package:flutter/foundation.dart';
1010
import 'package:photo_manager/photo_manager.dart';
11+
import 'package:wechat_assets_picker/src/constants/constants.dart';
1112

1213
@immutable
1314
class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
1415
AssetEntityImageProvider(
1516
this.entity, {
1617
this.scale = 1.0,
17-
this.thumbSize = const <int>[200, 200],
18+
this.thumbSize = Constants.defaultPreviewThumbSize,
1819
this.isOriginal = true,
1920
}) : assert(
20-
thumbSize?.length == 2,
21-
'thumbSize must contain and only contain two integers',
21+
isOriginal || thumbSize?.length == 2,
22+
'thumbSize must contain and only contain two integers when it\'s not original',
2223
) {
23-
if (thumbSize?.length != 2) {
24+
if (!isOriginal && thumbSize?.length != 2) {
2425
throw ArgumentError(
25-
'thumbSize must contain and only contain two integers',
26+
'thumbSize must contain and only contain two integers when it\'s not original',
2627
);
2728
}
2829
}

lib/src/widget/builder/audio_page_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import 'dart:async';
66

77
import 'package:flutter/material.dart';
88
import 'package:video_player/video_player.dart';
9+
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
910

1011
import 'package:wechat_assets_picker/src/constants/constants.dart';
11-
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
1212

1313
class AudioPageBuilder extends StatefulWidget {
1414
const AudioPageBuilder({

0 commit comments

Comments
 (0)