ice_tea_studio_plugins 0.0.1 copy "ice_tea_studio_plugins: ^0.0.1" to clipboard
ice_tea_studio_plugins: ^0.0.1 copied to clipboard

outdated

Ice Tea Studio Plugins

example/lib/main.dart

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),)),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Ice Tea Studio Plugins

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on ice_tea_studio_plugins