Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- import 'simple_icon_button.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar:AppBar(
- title: Text(widget.title),
- ),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- RaisedButton(
- onPressed: () {
- ///action disini
- //TODO : Ini Action Ketika Button di click
- _showToast();
- },
- child: Text(
- "Toast",
- style: TextStyle(
- color: Colors.white,
- ),
- ),
- color: Colors.blue,
- ),
- RaisedButton(
- child: Text("Simple Icon Button", style: TextStyle(color: Colors.white),),
- onPressed: (){
- //TODO : action pindah halaman ketika button di klik
- Navigator.of(context).push(MaterialPageRoute(builder: (context) => SimpleIconButton()));
- },
- color: Colors.blue,
- )
- ],
- ),
- ),
- );
- }
- void _showToast() {
- Fluttertoast.showToast(
- msg: "Ini adalah contoh short toast.",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIos: 1,
- backgroundColor: Colors.red,
- textColor: Colors.white);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement