updating example
This commit is contained in:
parent
af5da5e899
commit
82883db972
@ -1 +1 @@
|
|||||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_sms","path":"/Users/rodydavis/Developer/GitHub/plugins/packages/flutter_sms/","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_user_agent-1.2.2/","dependencies":[]},{"name":"url_launcher","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/","dependencies":[]}],"android":[{"name":"flutter_sms","path":"/Users/rodydavis/Developer/GitHub/plugins/packages/flutter_sms/","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_user_agent-1.2.2/","dependencies":[]},{"name":"url_launcher","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/","dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-2.0.0/","dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_sms","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows","url_launcher_web"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-04-05 14:01:11.011097","version":"2.1.0-13.0.pre.206"}
|
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_sms","path":"/Users/rodydavis/Developer/GitHub/plugins/packages/flutter_sms/","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_user_agent-1.2.2/","dependencies":[]},{"name":"url_launcher","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/","dependencies":[]}],"android":[{"name":"flutter_sms","path":"/Users/rodydavis/Developer/GitHub/plugins/packages/flutter_sms/","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_user_agent-1.2.2/","dependencies":[]},{"name":"url_launcher","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/","dependencies":[]}],"macos":[{"name":"url_launcher_macos","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-2.0.0/","dependencies":[]}],"web":[{"name":"url_launcher_web","path":"/usr/local/Caskroom/flutter/1.2.1/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_sms","dependencies":["url_launcher","flutter_user_agent"]},{"name":"flutter_user_agent","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows","url_launcher_web"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-04-05 14:03:03.497933","version":"2.1.0-13.0.pre.206"}
|
@ -1,35 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_sms/flutter_sms.dart';
|
import 'package:flutter_sms/flutter_sms.dart';
|
||||||
|
|
||||||
import 'dart:io' show Platform;
|
void main() => runApp(MyApp());
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
|
|
||||||
// The existing imports
|
|
||||||
// !! Keep your existing impots here !!
|
|
||||||
|
|
||||||
/// main is entry point of Flutter application
|
|
||||||
void main() {
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
if (!kIsWeb) _setTargetPlatformForDesktop();
|
|
||||||
return runApp(MyApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// If the current platform is desktop, override the default platform to
|
|
||||||
/// a supported platform (iOS for macOS, Android for Linux and Windows).
|
|
||||||
/// Otherwise, do nothing.
|
|
||||||
void _setTargetPlatformForDesktop() {
|
|
||||||
TargetPlatform targetPlatform;
|
|
||||||
if (Platform.isMacOS) {
|
|
||||||
targetPlatform = TargetPlatform.iOS;
|
|
||||||
} else if (Platform.isLinux || Platform.isWindows) {
|
|
||||||
targetPlatform = TargetPlatform.android;
|
|
||||||
}
|
|
||||||
if (targetPlatform != null) {
|
|
||||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@ -39,7 +13,7 @@ class MyApp extends StatefulWidget {
|
|||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
TextEditingController _controllerPeople, _controllerMessage;
|
TextEditingController _controllerPeople, _controllerMessage;
|
||||||
String _message, body;
|
String _message, body;
|
||||||
String _canSendSMSMessage = "Check is not run.";
|
String _canSendSMSMessage = 'Check is not run.';
|
||||||
List<String> people = [];
|
List<String> people = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -53,25 +27,26 @@ class _MyAppState extends State<MyApp> {
|
|||||||
_controllerMessage = TextEditingController();
|
_controllerMessage = TextEditingController();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendSMS(List<String> recipents) async {
|
Future<void> _sendSMS(List<String> recipients) async {
|
||||||
try {
|
try {
|
||||||
String _result = await sendSMS(
|
String _result = await sendSMS(
|
||||||
message: _controllerMessage.text, recipients: recipents);
|
message: _controllerMessage.text, recipients: recipients);
|
||||||
setState(() => _message = _result);
|
setState(() => _message = _result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setState(() => _message = error.toString());
|
setState(() => _message = error.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _canSendSMS() async {
|
Future<bool> _canSendSMS() async {
|
||||||
bool _result = await canSendSMS();
|
bool _result = await canSendSMS();
|
||||||
setState(() => _canSendSMSMessage =
|
setState(() => _canSendSMSMessage =
|
||||||
_result ? 'This unit can send SMS' : 'This unit cannot send SMS');
|
_result ? 'This unit can send SMS' : 'This unit cannot send SMS');
|
||||||
|
return _result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _phoneTile(String name) {
|
Widget _phoneTile(String name) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(3.0),
|
padding: const EdgeInsets.all(3),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
@ -81,22 +56,21 @@ class _MyAppState extends State<MyApp> {
|
|||||||
right: BorderSide(color: Colors.grey[300]),
|
right: BorderSide(color: Colors.grey[300]),
|
||||||
)),
|
)),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(4.0),
|
padding: const EdgeInsets.all(4),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.close),
|
icon: const 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),
|
||||||
child: Text(
|
child: Text(
|
||||||
name,
|
name,
|
||||||
textScaleFactor: 1.0,
|
textScaleFactor: 1,
|
||||||
style: TextStyle(fontSize: 12.0),
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -115,33 +89,32 @@ class _MyAppState extends State<MyApp> {
|
|||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
people == null || people.isEmpty
|
if (people == null || people.isEmpty)
|
||||||
? Container(
|
const SizedBox(height: 0)
|
||||||
height: 0.0,
|
else
|
||||||
)
|
SizedBox(
|
||||||
: Container(
|
height: 90,
|
||||||
height: 90.0,
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(3),
|
||||||
padding: const EdgeInsets.all(3.0),
|
child: ListView(
|
||||||
child: ListView(
|
scrollDirection: Axis.horizontal,
|
||||||
scrollDirection: Axis.horizontal,
|
children: List<Widget>.generate(people.length, (int index) {
|
||||||
children:
|
return _phoneTile(people[index]);
|
||||||
List<Widget>.generate(people.length, (int index) {
|
}),
|
||||||
return _phoneTile(people[index]);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.people),
|
leading: const Icon(Icons.people),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
controller: _controllerPeople,
|
controller: _controllerPeople,
|
||||||
decoration: InputDecoration(labelText: "Add Phone Number"),
|
decoration:
|
||||||
|
const InputDecoration(labelText: 'Add Phone Number'),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
onChanged: (String value) => setState(() {}),
|
onChanged: (String value) => setState(() {}),
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
onPressed: _controllerPeople.text.isEmpty
|
onPressed: _controllerPeople.text.isEmpty
|
||||||
? null
|
? null
|
||||||
: () => setState(() {
|
: () => setState(() {
|
||||||
@ -150,54 +123,55 @@ class _MyAppState extends State<MyApp> {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(),
|
const Divider(),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.message),
|
leading: const Icon(Icons.message),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
decoration: InputDecoration(labelText: " Add Message"),
|
decoration: const InputDecoration(labelText: 'Add Message'),
|
||||||
controller: _controllerMessage,
|
controller: _controllerMessage,
|
||||||
onChanged: (String value) => setState(() {}),
|
onChanged: (String value) => setState(() {}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(),
|
const Divider(),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Can send SMS"),
|
title: const Text('Can send SMS'),
|
||||||
subtitle: Text(_canSendSMSMessage),
|
subtitle: Text(_canSendSMSMessage),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
padding: EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
icon: Icon(Icons.check),
|
icon: const Icon(Icons.check),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_canSendSMS();
|
_canSendSMS();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.resolveWith(
|
backgroundColor: MaterialStateProperty.resolveWith(
|
||||||
(states) => Theme.of(context).accentColor),
|
(states) => Theme.of(context).accentColor),
|
||||||
padding: MaterialStateProperty.resolveWith(
|
padding: MaterialStateProperty.resolveWith(
|
||||||
(states) => EdgeInsets.symmetric(vertical: 16)),
|
(states) => const EdgeInsets.symmetric(vertical: 16)),
|
||||||
),
|
),
|
||||||
child: Text("SEND",
|
|
||||||
style: Theme.of(context).accentTextTheme.button),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_send();
|
_send();
|
||||||
},
|
},
|
||||||
|
child: Text(
|
||||||
|
'SEND',
|
||||||
|
style: Theme.of(context).accentTextTheme.button,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: _message != null,
|
visible: _message != null,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Text(
|
child: Text(
|
||||||
_message ?? "No Data",
|
_message ?? 'No Data',
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -213,7 +187,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
void _send() {
|
void _send() {
|
||||||
if (people == null || people.isEmpty) {
|
if (people == null || people.isEmpty) {
|
||||||
setState(() => _message = "At Least 1 Person or Message Required");
|
setState(() => _message = 'At Least 1 Person or Message Required');
|
||||||
} else {
|
} else {
|
||||||
_sendSMS(people);
|
_sendSMS(people);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_sms plugin.
|
|||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.1.0 <3.0.0"
|
sdk: ">=2.3.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
Loading…
Reference in New Issue
Block a user