Skip to content

Commit 9308a40

Browse files
committed
🥅 Throw error rather than assertion for stricter arguments.
1 parent de0ba04 commit 9308a40

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/src/provider/asset_picker_provider.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ class AssetPickerProvider extends ChangeNotifier {
6666
bool get isAssetsEmpty => _isAssetsEmpty;
6767

6868
set isAssetsEmpty(bool value) {
69-
assert(value != null);
70-
if (value == _isAssetsEmpty) {
69+
if (value == null || value == _isAssetsEmpty) {
7170
return;
7271
}
7372
_isAssetsEmpty = value;

lib/src/widget/asset_picker.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ class AssetPicker extends StatelessWidget {
8080
Curve routeCurve = Curves.easeIn,
8181
Duration routeDuration = const Duration(milliseconds: 300),
8282
}) async {
83-
assert(
84-
pageSize % gridCount == 0 || pageSize == null,
85-
'pageSize must be a multiple of gridCount.',
86-
);
87-
assert(
88-
pickerTheme == null || themeColor == null,
89-
'Theme and theme color cannot be set at the same time.',
90-
);
83+
if (maxAssets == null || maxAssets < 1) {
84+
throw ArgumentError('maxAssets must be greater than 1.');
85+
}
86+
if (pageSize % gridCount == 0 || pageSize == null) {
87+
throw ArgumentError('pageSize must be a multiple of gridCount.');
88+
}
89+
if (pickerTheme == null || themeColor == null) {
90+
throw ArgumentError('Theme and theme color cannot be set at the same time.');
91+
}
9192
try {
9293
final bool isPermissionGranted = await PhotoManager.requestPermission();
9394
if (isPermissionGranted) {

0 commit comments

Comments
 (0)