Custom Action with library gets Error: MissingPluginException

Custom Code

Hi there,

I'm trying to create a custom action. The code complies fine, but when I run the code, I get a Error: MissingPluginException.

The code compiles with no problem and I have another custom action with the same issue.

I'm using this library: flutter_contacts: ^1.1.7+1

It seems like it's being successfully imported?

Here's the whole error:

dart_sdk.js:11914 Uncaught (in promise) Error: MissingPluginException(No implementation found for method requestPermission on channel github.com/QuisApp/flutter_contacts)

at Object.throw_ [as throw] (dart_sdk.js:11914:11)

at MethodChannel._invokeMethod (platform_channel.dart:332:7)

at _invokeMethod.next (<anonymous>)

at dart_sdk.js:49722:33

at RootZone.runUnary (dartsdk.js:49577:59)

at FutureListener.thenAwait.handleValue (dartsdk.js:44704:29)

at handleValueCallback (dart_sdk.js:45304:49)

at Future.propagateToListeners (dart_sdk.js:45342:17)

at [_completeWithValue] (dart_sdk.js:45183:23)

at async._AsyncCallbackEntry.new.callback (dart_sdk.js:45217:35)

at Object._microtaskLoop (dart_sdk.js:50026:13)

at startMicrotaskLoop (dartsdk.js:50032:13)

at dart_sdk.js:45573:9

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/enums/enums.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:flutter_contacts/flutter_contacts.dart';

Future<List<UsersRecord>> fetchUsersFromContactBook() async {
  late List<Contact> _contacts;
  bool _permissionDenied = false;

  // Request contact permission
  if (await FlutterContacts.requestPermission()) {
    // Get all contacts (lightly fetched)

    final db = FirebaseFirestore.instance;
    List<Contact> contacts = await FlutterContacts.getContacts();
    for (Contact contact in contacts) {
      for (Email email in contact.emails) {
        print(db
            .collection('users')
            .where('email', isEqualTo: email.address)
            .get());
      }
    }
  }

  return [];
}
What have you tried so far?

I've confirm the import is in the pubspec.yaml file.

Did you check FlutterFlow's Documentation for this topic?
Yes
2
1 reply