listen_call 0.0.2+2 copy "listen_call: ^0.0.2+2" to clipboard
listen_call: ^0.0.2+2 copied to clipboard

PlatformAndroid

support background listen call phone event in android

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:listen_call/listen_call.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

///  callback function
int a = 0;
Future onPhoneCall(e) async {
  print(["onPhoneCall", e, a++]);
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

    /// requestPhonePermission
    ListenCall.requestPhonePermission;

    /// init
    ListenCall.initBackgroundCall(onPhoneCall);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
1
likes
110
pub points
27%
popularity

Publisher

verified publisherautopc.top

support background listen call phone event in android

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_easy_permission

More

Packages that depend on listen_call