ice_tea_studio_plugins 0.0.1 ice_tea_studio_plugins: ^0.0.1 copied to clipboard
Ice Tea Studio Plugins
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:ice_tea_studio_plugins/ice_tea_studio_plugins.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
String _platformMessage = '';
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = await NativeUtilsPlugin.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
showToastMessage() async {
try {
await NativeUtilsPlugin.showToast(
msg: "Hello Toast ${new DateTime.now()}",
backgroundColor: "#84db00",
gravity: ToastGravity.TOP,
isFullWidth: true);
if (!mounted) return;
setState(() {
_platformMessage = 'ok';
});
} on PlatformException {
_platformMessage = 'Failed to call show toast message.';
}
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Plugin example app x'),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text('Running status: $_platformMessage'),
new Container(
child: new Text('Running on: $_platformVersion'),
),
new Padding(padding: const EdgeInsets.only(top: 10.0)),
_buildButtonView('Show Toast', showToastMessage),
new Padding(padding: const EdgeInsets.only(top: 10.0)),
_buildButtonView('Show Warning Toast', showToastMessage),
new Padding(padding: const EdgeInsets.only(top: 10.0)),
_buildButtonView('Show Error Toast', showToastMessage),
],
)
),
),
);
}
Widget _buildButtonView(String text, VoidCallback callBack) {
return new FlatButton(
color: Colors.blue[700],
splashColor: Colors.blue[900],
padding: const EdgeInsets.all(0.0),
onPressed: callBack,
child: new Container(
width: 250.0,
alignment: Alignment.center,
padding: const EdgeInsets.all(10.0),
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(2.0),
// border: new Border.all(color: Colors.blue, width: 1.0)
),
child: new Text(
text.toUpperCase(), style: new TextStyle(color: Colors.white),)),
);
}
}