SHARE
TWEET

Untitled

a guest Nov 19th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3. import 'simple_icon_button.dart';
  4.  
  5. void main() => runApp(MyApp());
  6.  
  7. class MyApp extends StatelessWidget {
  8.   // This widget is the root of your application.
  9.   @override
  10.   Widget build(BuildContext context) {
  11.     return MaterialApp(
  12.       title: 'Flutter Demo',
  13.       theme: ThemeData(
  14.         primarySwatch: Colors.blue,
  15.       ),
  16.       home: MyHomePage(title: 'Flutter Demo Home Page'),
  17.     );
  18.   }
  19. }
  20.  
  21. class MyHomePage extends StatefulWidget {
  22.   MyHomePage({Key key, this.title}) : super(key: key);
  23.   final String title;
  24.  
  25.   @override
  26.   _MyHomePageState createState() => _MyHomePageState();
  27. }
  28.  
  29. class _MyHomePageState extends State<MyHomePage> {
  30.   @override
  31.   Widget build(BuildContext context) {
  32.     return Scaffold(
  33.       appBar:AppBar(
  34.         title: Text(widget.title),
  35.       ),
  36.       body: Center(
  37.         child: Column(
  38.           mainAxisAlignment: MainAxisAlignment.center,
  39.           children: <Widget>[
  40.             RaisedButton(
  41.               onPressed: () {
  42.                 ///action disini
  43.                 //TODO : Ini Action Ketika Button di click
  44.                 _showToast();
  45.               },
  46.               child: Text(
  47.                 "Toast",
  48.                 style: TextStyle(
  49.                   color: Colors.white,
  50.                 ),
  51.               ),
  52.               color: Colors.blue,
  53.             ),
  54.  
  55.             RaisedButton(
  56.               child: Text("Simple Icon Button", style: TextStyle(color: Colors.white),),
  57.               onPressed: (){
  58.                 //TODO : action pindah halaman ketika button di klik
  59.                 Navigator.of(context).push(MaterialPageRoute(builder: (context) => SimpleIconButton()));
  60.               },
  61.               color: Colors.blue,
  62.             )
  63.           ],
  64.         ),
  65.       ),
  66.     );
  67.   }
  68.  
  69.  
  70.   void _showToast() {
  71.     Fluttertoast.showToast(
  72.         msg: "Ini adalah contoh short toast.",
  73.         toastLength: Toast.LENGTH_SHORT,
  74.         gravity: ToastGravity.CENTER,
  75.         timeInSecForIos: 1,
  76.         backgroundColor: Colors.red,
  77.         textColor: Colors.white);
  78.   }
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top