Updated Example
This commit is contained in:
parent
3aad4f8a10
commit
25211934b2
@ -13,6 +13,9 @@ class MyApp extends StatefulWidget {
|
|||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
TextEditingController _controllerPeople, _controllerMessage;
|
TextEditingController _controllerPeople, _controllerMessage;
|
||||||
|
String _message, body;
|
||||||
|
List<String> people = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -51,7 +54,6 @@ class _MyAppState extends State<MyApp> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.close),
|
icon: Icon(Icons.close),
|
||||||
onPressed: () => setState(() => people.remove(name)),
|
onPressed: () => setState(() => people.remove(name)),
|
||||||
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(0.0),
|
padding: const EdgeInsets.all(0.0),
|
||||||
@ -67,19 +69,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _message, body;
|
|
||||||
List<String> people = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new MaterialApp(
|
return new MaterialApp(
|
||||||
home: new Scaffold(
|
home: new Scaffold(
|
||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
title: const Text('Plugin example app'),
|
title: const Text('SMS/MMS Example'),
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(title: Text('People')),
|
|
||||||
people == null || people.isEmpty
|
people == null || people.isEmpty
|
||||||
? Container(
|
? Container(
|
||||||
height: 0.0,
|
height: 0.0,
|
||||||
@ -101,6 +99,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
leading: Icon(Icons.people),
|
leading: Icon(Icons.people),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
controller: _controllerPeople,
|
controller: _controllerPeople,
|
||||||
|
decoration: InputDecoration(labelText: "Add Phone Number"),
|
||||||
onChanged: (String value) => setState(() {}),
|
onChanged: (String value) => setState(() {}),
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
@ -114,10 +113,10 @@ class _MyAppState extends State<MyApp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
ListTile(title: Text('Message')),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.message),
|
leading: Icon(Icons.message),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
|
decoration: InputDecoration(labelText: " Add Message"),
|
||||||
controller: _controllerMessage,
|
controller: _controllerMessage,
|
||||||
onChanged: (String value) => setState(() {}),
|
onChanged: (String value) => setState(() {}),
|
||||||
),
|
),
|
||||||
@ -140,12 +139,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
: Text(people.toString()),
|
: Text(people.toString()),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: Icon(Icons.send),
|
icon: Icon(Icons.send),
|
||||||
onPressed: (body == null || body.isEmpty) &&
|
onPressed: () {
|
||||||
(people == null || people.isEmpty)
|
if ((people == null || people.isEmpty) ||
|
||||||
? null
|
(body == null || body.isEmpty)) {
|
||||||
: () {
|
setState(() =>
|
||||||
_sendSMS(body, people);
|
_message = "At Least 1 Person or Message Required");
|
||||||
},
|
} else {
|
||||||
|
_sendSMS(body, people);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
|
Loading…
Reference in New Issue
Block a user