phonecallstate 0.0.1 copy "phonecallstate: ^0.0.1" to clipboard
phonecallstate: ^0.0.1 copied to clipboard

outdatedDart 1 only

Flutter plugin to receive Phone Call State for both iOS and Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:phonecallstate/phonecallstate.dart';

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

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

enum PhonecallState { incoming, dialing, connected, disconnected, none }
enum PhonecallStateError { notimplementedyet  }

class _MyAppState extends State<MyApp> {

  Phonecallstate  phonecallstate;
  PhonecallState phonecallstatus;

  var  phonecallstatuslog;

  @override
  initState() {
    super.initState();
    initPhonecallstate();
  }

  void initPhonecallstate() async {
    print("Phonecallstate init");

    phonecallstate = new Phonecallstate();
    phonecallstatus = PhonecallState.none;


    phonecallstate.setIncomingHandler(() {
      setState(() {
        phonecallstatus = PhonecallState.incoming;
        phonecallstatuslog =  phonecallstatuslog.toString() + PhonecallState.incoming.toString()+"\n";
      });
    });

    phonecallstate.setDialingHandler(() {
      setState(() {
        phonecallstatus = PhonecallState.dialing;
        phonecallstatuslog =  phonecallstatuslog.toString() + PhonecallState.dialing.toString()+"\n";
      });
    });

    phonecallstate.setConnectedHandler(() {
      setState(() {
        phonecallstatus = PhonecallState.connected;
        phonecallstatuslog =  phonecallstatuslog.toString() + PhonecallState.connected.toString()+"\n";
      });
    });

    phonecallstate.setDisconnectedHandler(() {
      setState(() {
        phonecallstatus = PhonecallState.disconnected;
        phonecallstatuslog =  phonecallstatuslog.toString() + PhonecallState.disconnected.toString()+"\n";
      });
    });

    phonecallstate.setErrorHandler((msg) {

    });
  }





  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Phone Call State example app'),
        ),
        body: new Text('Last state: $phonecallstatuslog'),
      ),
    );
  }
}
3
likes
30
pub points
14%
popularity

Publisher

unverified uploader

Flutter plugin to receive Phone Call State for both iOS and Android.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on phonecallstate