flutter_call_phone_intent 0.0.3 copy "flutter_call_phone_intent: ^0.0.3" to clipboard
flutter_call_phone_intent: ^0.0.3 copied to clipboard

An Android direct call and hang up delete call history.

example/lib/main.dart

import 'dart:developer';

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  final _flutterPhoneCallAutoPlugin = FlutterCallPhoneIntent();

  @override
  void initState() {
    super.initState();
    initData();
  }

  initData() async {
    await _flutterPhoneCallAutoPlugin.init();
    await _flutterPhoneCallAutoPlugin.requestPermissions();
    _flutterPhoneCallAutoPlugin.onCallStateChanged().listen((event) {
      log('-----------呼叫状态变化:$event------------');
      //呼叫中 OFFHOOK
      //挂断 IDLE
    });
  }

  onCallPhone() async {
    if (await _flutterPhoneCallAutoPlugin.checkPermissions() ?? false) {
      var number = await _flutterPhoneCallAutoPlugin.callPhone('11111122233');
      log('-----------拨打电话:$number------------');
    } else {
      await _flutterPhoneCallAutoPlugin.requestPermissions();
    }
  }

  onEndPhone() async {
    await _flutterPhoneCallAutoPlugin.endCall();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            InkWell(
              onTap: onCallPhone,
              child: Container(
                padding: const EdgeInsets.all(20),
                child: Text('callPhone'),
              ),
            ),
            SizedBox(height: 20),
            InkWell(
              onTap: onEndPhone,
              child: Container(
                padding: const EdgeInsets.all(20),
                child: Text('endCall'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
0
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

An Android direct call and hang up delete call history.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_call_phone_intent

Packages that implement flutter_call_phone_intent