diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index a61a29b..d6c73c8 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index aa068c7..08291c3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,35 +1,9 @@ -import 'package:flutter/material.dart'; import 'dart:async'; +import 'package:flutter/material.dart'; import 'package:flutter_sms/flutter_sms.dart'; -import 'dart:io' show Platform; -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; - } -} +void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override @@ -39,7 +13,7 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { TextEditingController _controllerPeople, _controllerMessage; String _message, body; - String _canSendSMSMessage = "Check is not run."; + String _canSendSMSMessage = 'Check is not run.'; List people = []; @override @@ -53,25 +27,26 @@ class _MyAppState extends State { _controllerMessage = TextEditingController(); } - void _sendSMS(List recipents) async { + Future _sendSMS(List recipients) async { try { String _result = await sendSMS( - message: _controllerMessage.text, recipients: recipents); + message: _controllerMessage.text, recipients: recipients); setState(() => _message = _result); } catch (error) { setState(() => _message = error.toString()); } } - void _canSendSMS() async { + Future _canSendSMS() async { bool _result = await canSendSMS(); setState(() => _canSendSMSMessage = _result ? 'This unit can send SMS' : 'This unit cannot send SMS'); + return _result; } Widget _phoneTile(String name) { return Padding( - padding: const EdgeInsets.all(3.0), + padding: const EdgeInsets.all(3), child: Container( decoration: BoxDecoration( border: Border( @@ -81,22 +56,21 @@ class _MyAppState extends State { right: BorderSide(color: Colors.grey[300]), )), child: Padding( - padding: EdgeInsets.all(4.0), + padding: const EdgeInsets.all(4), child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ IconButton( - icon: Icon(Icons.close), + icon: const Icon(Icons.close), onPressed: () => setState(() => people.remove(name)), ), Padding( - padding: const EdgeInsets.all(0.0), + padding: const EdgeInsets.all(0), child: Text( name, - textScaleFactor: 1.0, - style: TextStyle(fontSize: 12.0), + textScaleFactor: 1, + style: const TextStyle(fontSize: 12), ), ) ], @@ -115,33 +89,32 @@ class _MyAppState extends State { ), body: ListView( children: [ - people == null || people.isEmpty - ? Container( - height: 0.0, - ) - : Container( - height: 90.0, - child: Padding( - padding: const EdgeInsets.all(3.0), - child: ListView( - scrollDirection: Axis.horizontal, - children: - List.generate(people.length, (int index) { - return _phoneTile(people[index]); - }), - ), - ), + if (people == null || people.isEmpty) + const SizedBox(height: 0) + else + SizedBox( + height: 90, + child: Padding( + padding: const EdgeInsets.all(3), + child: ListView( + scrollDirection: Axis.horizontal, + children: List.generate(people.length, (int index) { + return _phoneTile(people[index]); + }), ), + ), + ), ListTile( - leading: Icon(Icons.people), + leading: const Icon(Icons.people), title: TextField( controller: _controllerPeople, - decoration: InputDecoration(labelText: "Add Phone Number"), + decoration: + const InputDecoration(labelText: 'Add Phone Number'), keyboardType: TextInputType.number, onChanged: (String value) => setState(() {}), ), trailing: IconButton( - icon: Icon(Icons.add), + icon: const Icon(Icons.add), onPressed: _controllerPeople.text.isEmpty ? null : () => setState(() { @@ -150,54 +123,55 @@ class _MyAppState extends State { }), ), ), - Divider(), + const Divider(), ListTile( - leading: Icon(Icons.message), + leading: const Icon(Icons.message), title: TextField( - decoration: InputDecoration(labelText: " Add Message"), + decoration: const InputDecoration(labelText: 'Add Message'), controller: _controllerMessage, onChanged: (String value) => setState(() {}), ), ), - Divider(), + const Divider(), ListTile( - title: Text("Can send SMS"), + title: const Text('Can send SMS'), subtitle: Text(_canSendSMSMessage), trailing: IconButton( - padding: EdgeInsets.symmetric(vertical: 16), - icon: Icon(Icons.check), + padding: const EdgeInsets.symmetric(vertical: 16), + icon: const Icon(Icons.check), onPressed: () { _canSendSMS(); }, ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (states) => Theme.of(context).accentColor), padding: MaterialStateProperty.resolveWith( - (states) => EdgeInsets.symmetric(vertical: 16)), + (states) => const EdgeInsets.symmetric(vertical: 16)), ), - child: Text("SEND", - style: Theme.of(context).accentTextTheme.button), onPressed: () { _send(); }, + child: Text( + 'SEND', + style: Theme.of(context).accentTextTheme.button, + ), ), ), Visibility( visible: _message != null, child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Padding( - padding: const EdgeInsets.all(12.0), + padding: const EdgeInsets.all(12), child: Text( - _message ?? "No Data", + _message ?? 'No Data', maxLines: null, ), ), @@ -213,7 +187,7 @@ class _MyAppState extends State { void _send() { if (people == null || people.isEmpty) { - setState(() => _message = "At Least 1 Person or Message Required"); + setState(() => _message = 'At Least 1 Person or Message Required'); } else { _sendSMS(people); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index edcff19..1554b4a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_sms plugin. publish_to: 'none' environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.3.0 <3.0.0" dependencies: flutter: