import 'package:flutter/material.dart';
import 'package:sms/sms.dart';
void main() => runApp(QuickBee());
String mTitle=" ";
IconData _iconData;
class QuickBee extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Imik',
debugShowCheckedModeBanner: false,
// Set Raleway as the default app font
theme: ThemeData(
fontFamily: 'Roboto',
),
home: MyHomePage(),
);
}
}
void receiveMsg() {
SmsReceiver receiver = new SmsReceiver();
receiver.onSmsReceived.listen((SmsMessage msg) =>mTitle=(msg.body));
}
void testAlert(BuildContext context) {
Widget okButton = FlatButton(
child: Text("OK"),
onPressed: () {
Navigator.of(context).pop();
},
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
);
var alert = AlertDialog(
contentPadding: EdgeInsets.only(top: 10.0),
title: Text("The recently received msg is"),
content: Text("$mTitle"),
actions: [
okButton,
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
});
}
void onoff(){
if(mTitle=='On'){
_iconData = Icons.notifications;
}
else if(mTitle=='Off'){
_iconData = Icons.notifications;
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Title"),
actions: <Widget>[
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Stack(
alignment: Alignment.center,
children: <Widget>[
new Container(
height: 60.0,
width: 60.0,
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(50.0),
color: Color(0xFF45E0EC)),
child: new Icon(
Icons.build,
color: Colors.white,
),
),
new Container(
margin: new EdgeInsets.only(right: 50.0, top: 50.0),
height: 60.0,
width: 60.0,
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(50.0),
color: Color(0xFFFC6A7F)),
child: new Icon(
Icons.device_hub,
color: Colors.white,
),
),
new Container(
margin: new EdgeInsets.only(left: 30.0, top: 50.0),
height: 60.0,
width: 60.0,
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(50.0),
color: Color(0xFFFFCE56)),
child: new Icon(
Icons.phonelink,
color: Colors.white,
),
),
new Container(
margin: new EdgeInsets.only(left: 90.0, top: 40.0),
height: 60.0,
width: 60.0,
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(50.0),
color: Color(0xFF18D191)),
child: new Icon(
Icons.memory,
color: Colors.white,
),
)
],
),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 80.0),
child: new Text(
"Receive SMS",
style: new TextStyle(fontSize: 30.0,fontWeight: FontWeight.bold),
),
)
],
),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
/*Center(
child: RaisedButton(
padding: const EdgeInsets.only(left: 20.0, right: 5.0, top: 10.0),
color: Colors.black,
textColor: Colors.white,
onPressed: () {
receiveMsg();
testAlert(context);
},
child: Text("Show notification"),
),
),*/
Expanded(
child: RaisedButton(
onPressed: () {
receiveMsg();
testAlert(context);
},
child: new Container(
alignment: Alignment.center,
height: 60.0,
decoration: new BoxDecoration(
color: Color(0xFFDF513B),
borderRadius: new BorderRadius.circular(9.0)),
child: new Text("Show notification",
style: new TextStyle(
fontSize: 20.0, color: Colors.white))),
),
),
],
)
],
),
),
);
}
}