Skip to content

Commit

Permalink
Fix analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Aug 16, 2024
1 parent b8d3182 commit 9ea0aff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions permission_handler_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ final MaterialColor themeMaterialColor =

/// A Flutter application demonstrating the functionality of this plugin
class PermissionHandlerWidget extends StatefulWidget {
/// Creates a [PermissionHandlerWidget].
const PermissionHandlerWidget({
super.key,
});

/// Create a page containing the functionality of this plugin
static ExamplePage createPage() {
return ExamplePage(
Icons.location_on, (context) => PermissionHandlerWidget());
Icons.location_on, (context) => const PermissionHandlerWidget());
}

@override
Expand Down Expand Up @@ -54,18 +59,20 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
/// Permission widget containing information about the passed [Permission]
class PermissionWidget extends StatefulWidget {
/// Constructs a [PermissionWidget] for the supplied [Permission]
const PermissionWidget(this._permission);
const PermissionWidget(
this._permission, {
super.key,
});

final Permission _permission;

@override
_PermissionState createState() => _PermissionState(_permission);
_PermissionState createState() => _PermissionState();
}

class _PermissionState extends State<PermissionWidget> {
_PermissionState(this._permission);
_PermissionState();

final Permission _permission;
final PermissionHandlerPlatform _permissionHandler =
PermissionHandlerPlatform.instance;
PermissionStatus _permissionStatus = PermissionStatus.denied;
Expand All @@ -78,7 +85,8 @@ class _PermissionState extends State<PermissionWidget> {
}

void _listenForPermissionStatus() async {
final status = await _permissionHandler.checkPermissionStatus(_permission);
final status =
await _permissionHandler.checkPermissionStatus(widget._permission);
setState(() => _permissionStatus = status);
}

Expand All @@ -99,26 +107,26 @@ class _PermissionState extends State<PermissionWidget> {
Widget build(BuildContext context) {
return ListTile(
title: Text(
_permission.toString(),
widget._permission.toString(),
style: Theme.of(context).textTheme.bodyLarge,
),
subtitle: Text(
_permissionStatus.toString(),
style: TextStyle(color: getPermissionColor()),
),
trailing: (_permission is PermissionWithService)
trailing: (widget._permission is PermissionWithService)
? IconButton(
icon: const Icon(
Icons.info,
color: Colors.white,
),
onPressed: () {
checkServiceStatus(
context, _permission as PermissionWithService);
context, widget._permission as PermissionWithService);
})
: null,
onTap: () {
requestPermission(_permission);
requestPermission(widget._permission);
},
);
}
Expand All @@ -135,9 +143,7 @@ class _PermissionState extends State<PermissionWidget> {
final status = await _permissionHandler.requestPermissions([permission]);

setState(() {
print(status);
_permissionStatus = status[permission] ?? PermissionStatus.denied;
print(_permissionStatus);
});
}
}
2 changes: 1 addition & 1 deletion permission_handler_android/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: permission_handler_android_example
description: Demonstrates how to use the permission_handler_android plugin.

environment:
sdk: ">=2.15.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"

dependencies:
baseflow_plugin_template: ^2.1.2
Expand Down

0 comments on commit 9ea0aff

Please sign in to comment.