Reputation: 35
I am importing the
permission_handler plug-in and the
location plug-in.
The problem is that both of these have a class called PermissionStatus, and I need to use PermissionStatus.granted from the location plug-in, since I am requesting permission to access location from the location plug-in. So what I need someone to explain to me is either
a) How to fix the problem of using a class from one plugin, that happens to be in another plugin I imported under the same name.
or
b) How to properly request permission for access to location using only permission_handler
Upvotes: 0
Views: 1865
Reputation: 14043
If you have import two libraries
that have conflicting identifiers, then you can specify an import prefix
for one or both libraries
.
For example, if library1
and library2
both have an Element
class, then you might have code like this:
import 'package:lib1/lib1.dart';
import 'package:lib2/lib2.dart' as lib2;
// use in your code like
Element libraryOneElement = Element(); // from library one
lib2.Element libraryTwoElement = lib2.Element(); // from library two
A demo using your code as an example:
import '...permission_handler...';
import '... location...' as location;
// use in your code like
var permissionHandlerStatus = PermissionStatus.granted;
var locationPermissionStatus = location.PermissionStatus.granted;
Upvotes: 11