flutter_phone 0.0.31
flutter_phone: ^0.0.31 copied to clipboard
Flutter plugin for phone call,phone logs,phone,audio.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_phone/flutter_phone.dart';
import 'global.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _phone = FlutterPhone();
TextEditingController _controller = TextEditingController();
Map map = Global.getConfig();
@override
void initState() {
super.initState();
initPlatformState();
}
changeMap(String text) {
setState(() {
// map = Global.getConfig();
print(text);
});
}
// 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.
// We also handle the message potentially returning null.
try {
platformVersion = await _phone.getPlatformVersion() ?? 'Unknown platform version';
await _phone.permission();
// _phone.toCall({"phone":"13578021300","id":0});
_phone.appTask(map);
} 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;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text('Running on: $_platformVersion\n',textAlign: TextAlign.center,),
TextField(
controller: _controller,
decoration: InputDecoration(
labelText: "同步多少天电话量",
hintText: map.toString(),
),
onChanged: changeMap,
),
TextButton(
onPressed: initPlatformState,
child: Text("同步通话录音"),
style: ButtonStyle(
textStyle: MaterialStateProperty.all(TextStyle(fontSize: 18)),
padding: MaterialStateProperty.all(EdgeInsets.all(10)),
backgroundColor: MaterialStateProperty.all(Colors.red),
foregroundColor: MaterialStateProperty.all(Colors.amberAccent)
),
)
],
),
)
),
);
}
}