xdh_call 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 36

xdh_call #

通话状态监听(目前仅仅支持安卓)

Getting Started #

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.READ_SMS"/>

Example #

// IMPORT PACKAGE
import 'package:xdh_call/xdh_call.dart';

//监听通话状态
//1.初始化
XdhCall(_onEvent,_onError);
//2.定义回调方法
  void _onEvent(Object event) {
    print("调用自定义收到回复");
    setState(() {
      _platformVersion = event;
    });
    print(event);
  }

  void _onError(Object error) {
    print("收到错误");
  }
 // 拨打电话返回 "{'type':'outgoning_call','phone':'10086'}"
 // 挂断 "{'type':'call_state_idle','phone':'10086'}"
 // 接听 "{'type':'call_state_offhook','phone':'10086'}"
 // 呼入响铃 "{'type':'call_state_ringing','phone':'10086'}"

 //拨打系统电话
 //无需二次确认方式
 XdhCall.callphone("call",is_confirm:false,phone_number:'10086');
 //需要二次确认方式
 XdhCall.callphone("call",is_confirm:true,phone_number:'10086');

配合 call_log 你会有意想不到的组合 #

https://pub.dartlang.org/packages/call_log

上传感谢 https://www.cnblogs.com/yangyxd/p/9234405.html This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.1 #

  • 实现功能

0.0.2 #

  • 更新readme

0.0.3 #

  • 添加 两种拨打电话方式

0.0.4 #

  • 添加 发短信

0.0.6 #

  • 添加获取设备唯一标识

0.0.7 #

  • 获取通话记录

example/lib/main.dart

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

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
    XdhCall(_onEvent,_onError);
  }

  void _onEvent(Object event) {
    print("调用自定义收到回复");
    setState(() {
      _platformVersion = event;
    });
    print(event);
  }

  void _onError(Object error) {
    print("收到错误");
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await XdhCall.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }
  _sendsm() async {
    if(await XdhCall.sendSms(phone_number: "13252033403",sms_content: "测试啦啦啦啦")){
      setState(() {
          _platformVersion = "发送成功";
        });
    }
  }
  
  _getUniqueId() async {
    String str = await XdhCall.getUniqueId();
    setState(() {
	  _platformVersion = str;
	});
  }

  _getCallLog() async {
    String str = await XdhCall.getCallLogByWhere("NUMBER = 10086 and DURATION > 0","DATE desc");
    print(str);
    setState(() {
      _platformVersion = str;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(children: <Widget>[
            Text('Running on: $_platformVersion\n'),
            FlatButton(onPressed: (){
              XdhCall.callphone("call",is_confirm:false,phone_number:'10086');
            },child: new Text("无需确认方式拨打电话"),),
            FlatButton(onPressed: (){
              XdhCall.callphone("call",is_confirm:true,phone_number:'10086');
            },child: new Text("需确认方式拨打电话"),),
            FlatButton(onPressed: (){
              XdhCall.endCall();
            },child: new Text("挂断电话"),),
            FlatButton(onPressed: (){
              _sendsm();
            },child: new Text("发送短信"),),
            FlatButton(onPressed: (){
                    _getUniqueId();
            },child: new Text("获取唯一设备id"),),
            FlatButton(onPressed: (){
              _getCallLog();
            },child: new Text("获取记录"),),

          ],)
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  xdh_call: ^0.0.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:xdh_call/xdh_call.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
32
Overall:
Weighted score of the above. [more]
36
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:xdh_call/xdh_call.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:xdh_call/xdh_call.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:xdh_call/xdh_call.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:xdh_call/xdh_call.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • xdh_call that is a package requiring null.

Health suggestions

Fix lib/xdh_call.dart. (-1.99 points)

Analysis of lib/xdh_call.dart reported 4 hints:

line 18 col 10: Name non-constant identifiers using lowerCamelCase.

line 19 col 12: Name non-constant identifiers using lowerCamelCase.

line 53 col 12: Name non-constant identifiers using lowerCamelCase.

line 54 col 12: Name non-constant identifiers using lowerCamelCase.

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-18.08 points)

The package was last published 61 weeks ago.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety