-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonerecall.dart
62 lines (57 loc) · 1.67 KB
/
phonerecall.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import 'packagefluttermaterial.dart';
class PhoneRecall extends StatefulWidget {
@override
_PhoneRecallState createState() = _PhoneRecallState();
}
class _PhoneRecallState extends StatePhoneRecall {
TextEditingController _phoneNumberController = TextEditingController();
bool _phoneNumberValid = false;
void _validatePhoneNumber(String phoneNumber) {
Regular expression to match a valid phone number
RegExp regExp = new RegExp(r'^d{10}$');
if (regExp.hasMatch(phoneNumber)) {
setState(() {
_phoneNumberValid = true;
});
} else {
setState(() {
_phoneNumberValid = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar AppBar(
title Text('Phone Recall'),
),
body Container(
padding EdgeInsets.all(16.0),
child Column(
children Widget[
TextField(
controller _phoneNumberController,
decoration InputDecoration(
labelText 'Phone Number',
),
onChanged (value) {
_validatePhoneNumber(value);
},
),
SizedBox(height 16.0),
RaisedButton(
child Text('Recall'),
onPressed _phoneNumberValid
() {
Implement phone recall functionality here
String phoneNumber = _phoneNumberController.text;
Do something with the phone number
}
null,
),
],
),
),
);
}
}