I have a text field in which user enters a number and a Raisedbutton.By clicking that button user should be able to make call on that number . How to write onPressed() function for that buton??
Above this code I have my main class in which Home() class is getting called
import 'package:flutter/material.dart';
class Home extends StatefulWidget{
@override
State<StatefulWidget> createState() {
return HomeState();
}
}
class HomeState extends State<Home> {
TextEditingController numcontroller = new TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.deepPurple,
title: Text('Calling App'),
),
body: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 60.0, left: 10.0, right: 10.0),
child: TextField(
controller: numcontroller,
decoration: InputDecoration(
labelText: 'Enter Phone Number',
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.deepPurple,
)
)
)
),
),
Container(
height: 45.0,
width: 90.0,
margin: EdgeInsets.only(top: 40, left: 10, right: 10.0),
child: RaisedButton(
color: Colors.deepPurple,
elevation: 7.0,
child: Text(
'Call',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
_calling();
}
),
)
],
),
),
);
}
void _calling(){
}
}
suppose I have entered a number 94********.then on pressing that button the call should be connected to this number .If busy or switch off then should show any alert message.