Skip to content

Commit b05d3a5

Browse files
HubHivematthewbrown62AlexV525
authored
feat: added isLimited to permission state extension (#1295)
Co-authored-by: Matthew Brown <matthew@brainspin.com> Co-authored-by: Alex Li <github@alexv525.com>
1 parent c62430b commit b05d3a5

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ To know more about breaking changes, see the [Migration Guide][].
3030
- Remove implied `FilterOptionGroup`s when querying paths and assets.
3131
This fixes assets finding when they were created in the future.
3232
Some edge cases regarding performance drops caused by the complicated sort queries might also get fixed.
33+
- Add `PermissionState.isLimited`.
3334

3435
### Fixes
3536

lib/src/internal/extensions.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ extension PermissionStateExt on PermissionState {
1313

1414
/// Returns `true` if the permission grants partial or full access to assets; otherwise, `false`.
1515
bool get hasAccess {
16-
return this == PermissionState.authorized ||
17-
this == PermissionState.limited;
16+
return this == PermissionState.authorized || this == PermissionState.limited;
17+
}
18+
19+
bool get isLimited {
20+
return this == PermissionState.limited;
1821
}
1922
}

test/internal/extensions_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ void main() {
1313
equals(true),
1414
);
1515
expect(
16-
permission.hasAccess ==
17-
(permission == PermissionState.authorized ||
18-
permission == PermissionState.limited),
16+
permission.hasAccess == (permission == PermissionState.authorized || permission == PermissionState.limited),
17+
equals(true),
18+
);
19+
expect(
20+
permission.isLimited == (permission == PermissionState.limited),
1921
equals(true),
2022
);
2123
});

0 commit comments

Comments
 (0)