Advertisement
AbiMulya

(Belajar Flutter) Anonymous Method

Oct 6th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.07 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatefulWidget {
  8.   @override
  9.   _MyAppState createState() => _MyAppState();
  10. }
  11.  
  12. class _MyAppState extends State<MyApp> {
  13.   String message = "Ini Text";
  14.   // void tombolDitekan() {
  15.   //   setState(() {
  16.   //     message = "Tombol ditekan";
  17.   //   });
  18.   // }
  19.  
  20.   // This widget is the root of your application.
  21.   @override
  22.   Widget build(BuildContext context) {
  23.     return MaterialApp(
  24.       home: Scaffold(
  25.         appBar: AppBar(
  26.           title: Text("Anonymous Method"),
  27.         ),
  28.         body: Center(
  29.           child: Column(
  30.             mainAxisAlignment: MainAxisAlignment.center,
  31.             children: <Widget>[
  32.               Text(message),
  33.               RaisedButton(
  34.                 child: Text("Tekan ini bosquee"),
  35.                 onPressed: () {
  36.                   setState(() {
  37.                     message = "Tombol ditekan";
  38.                   });
  39.                 },
  40.               )
  41.             ],
  42.           ),
  43.         ),
  44.       ),
  45.     );
  46.   }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement