1
votes

Trying to write a permission code for camera and microphone on flutter

I'm currently using permission_handler: ^5.0.1 and have imported the package after adding the dependency in pubspec.yaml

import 'package:permission_handler/permission_handler.dart';

But when I used the following code,

await Permission.camera.request();

I have the following error.

Undefined name 'Permission'. Try correcting the name to one that is defined, or defining the name.

Any help will be appreciated. Thanks!

2

2 Answers

1
votes

I realized later that the error was because I accidentally deleted permission_handler_platform_interface-2.0.2 in my external packages inside the External Libraries > Dart Packages in Flutter SDK.

I resolved it by running

flutter pub cache repair
0
votes

Try read the docs again. Maybe they have change the code or maybe make sure that you have get the package.