Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
df98ac28
Unverified
Commit
df98ac28
authored
Apr 14, 2021
by
Maurits van Beusekom
Committed by
GitHub
Apr 14, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #515 from Baseflow/equality
Implement equality for Permission
parents
28b3caae
9c849ea9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
2 deletions
+77
-2
permission_handler_platform_interface/CHANGELOG.md
+5
-0
permission_handler_platform_interface/lib/src/permissions.dart
+16
-1
permission_handler_platform_interface/pubspec.yaml
+1
-1
permission_handler_platform_interface/test/src/permissions_test.dart
+55
-0
No files found.
permission_handler_platform_interface/CHANGELOG.md
View file @
df98ac28
## 3.1.3
*
Implemented equality operator for
`Permission`
class;
*
Reverted services status check for notification permission. Turns out implementation does not fit with idea's of permission_handler plugin.
## 3.1.2
## 3.1.2
*
Allow checking serviceStatus for notification permission.
*
Allow checking serviceStatus for notification permission.
...
...
permission_handler_platform_interface/lib/src/permissions.dart
View file @
df98ac28
...
@@ -11,6 +11,7 @@ class PermissionWithService extends Permission {
...
@@ -11,6 +11,7 @@ class PermissionWithService extends Permission {
}
}
/// Defines the permissions which can be checked and requested.
/// Defines the permissions which can be checked and requested.
@immutable
class
Permission
{
class
Permission
{
const
Permission
.
_
(
this
.
value
);
const
Permission
.
_
(
this
.
value
);
factory
Permission
.
byValue
(
int
value
)
=>
values
[
value
];
factory
Permission
.
byValue
(
int
value
)
=>
values
[
value
];
...
@@ -92,7 +93,7 @@ class Permission {
...
@@ -92,7 +93,7 @@ class Permission {
/// Android: Notification
/// Android: Notification
/// iOS: Notification
/// iOS: Notification
static
const
notification
=
Permission
WithService
.
_
(
17
);
static
const
notification
=
Permission
.
_
(
17
);
/// Android: Allows an application to access any geographic locations
/// Android: Allows an application to access any geographic locations
/// persisted in the user's shared collection.
/// persisted in the user's shared collection.
...
@@ -163,4 +164,18 @@ class Permission {
...
@@ -163,4 +164,18 @@ class Permission {
@override
@override
String
toString
()
=>
'Permission.
${_names[value]}
'
;
String
toString
()
=>
'Permission.
${_names[value]}
'
;
@override
bool
operator
==(
Object
other
)
{
if
(
identical
(
this
,
other
))
{
return
true
;
}
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
Permission
&&
other
.
value
==
value
;
}
@override
int
get
hashCode
=>
value
.
hashCode
;
}
}
permission_handler_platform_interface/pubspec.yaml
View file @
df98ac28
...
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
...
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
homepage
:
https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
homepage
:
https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version
:
3.1.
2
version
:
3.1.
3
dependencies
:
dependencies
:
flutter
:
flutter
:
...
...
permission_handler_platform_interface/test/src/permissions_test.dart
View file @
df98ac28
...
@@ -22,4 +22,59 @@ void main() {
...
@@ -22,4 +22,59 @@ void main() {
var
permissionName
=
permissionWithService
.
toString
();
var
permissionName
=
permissionWithService
.
toString
();
expect
(
permissionName
,
'Permission.calendar'
);
expect
(
permissionName
,
'Permission.calendar'
);
});
});
test
(
// ignore: lines_longer_than_80_chars
'equality operator should return true for two instances with the same values'
,
()
{
// Arrange
final
firstPermission
=
Permission
.
byValue
(
1
);
final
secondPermission
=
Permission
.
byValue
(
1
);
// Act & Assert
expect
(
firstPermission
==
secondPermission
,
true
,
);
});
test
(
// ignore: lines_longer_than_80_chars
'equality operator should return false for two instances with different values'
,
()
{
// Arrange
final
firstPermission
=
Permission
.
byValue
(
1
);
final
secondPermission
=
Permission
.
byValue
(
2
);
// Act & Assert
expect
(
firstPermission
==
secondPermission
,
false
,
);
});
test
(
'hashCode should be the same for two instances with the same values'
,
()
{
// Arrange
final
firstPermission
=
Permission
.
byValue
(
1
);
final
secondPermission
=
Permission
.
byValue
(
1
);
// Act & Assert
expect
(
firstPermission
.
hashCode
,
secondPermission
.
hashCode
,
);
});
test
(
'hashCode should not match for two instances with different values'
,
()
{
// Arrange
final
firstPermission
=
Permission
.
byValue
(
1
);
final
secondPermission
=
Permission
.
byValue
(
2
);
// Act & Assert
expect
(
firstPermission
.
hashCode
==
secondPermission
.
hashCode
,
false
,
);
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment