Advertisement
yocky12k

flutter widget 2

Oct 24th, 2023 (edited)
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 6.12 KB | None | 0 0
  1. catatan: di bagian pubspec.yaml di tambahin seperti ini
  2. dependencies:
  3.   flutter:
  4.     sdk: flutter
  5.   fluttertoast: ^8.2.2
  6.  
  7.  
  8. import 'package:flutter/material.dart';
  9. import 'package:fluttertoast/fluttertoast.dart';
  10.  
  11. void main() {
  12.   runApp(const MainApp());
  13. }
  14.  
  15. class MainApp extends StatelessWidget {
  16.   const MainApp({super.key});
  17.  
  18.   @override
  19.   Widget build(BuildContext context) {
  20.     return MaterialApp(
  21.       home: Scaffold(
  22.         appBar: AppBar(
  23.           title: Text('Latihan Widget 2'),
  24.         ),
  25.         drawer: Drawer(
  26.           child: ListView(
  27.             children: [
  28.               UserAccountsDrawerHeader(
  29.                 accountName: Text('STMIK ROYAL'),
  30.                 accountEmail: Text('yockykisaran466@gmail.com'),
  31.                 currentAccountPicture: CircleAvatar(
  32.                   backgroundImage: AssetImage('images/profile.jpeg'),
  33.                 ),
  34.                 ),
  35.               ListTile(
  36.                 leading: Icon(Icons.home),
  37.                 title: Text('Home'),
  38.                 onTap: (){
  39.                   //logic menu ketika di tekan
  40.                   Fluttertoast.showToast(
  41.                     msg: "Anda menekan home",
  42.                     toastLength: Toast.LENGTH_SHORT,
  43.                     gravity: ToastGravity.BOTTOM,
  44.                     fontSize: 15.0,
  45.                   );
  46.                 },
  47.               ),
  48.               ListTile(
  49.                 leading: Icon(Icons.inbox),
  50.                 title: Text('Inbox'),
  51.                 onTap: (){
  52.                   //logic menu ketika di tekan
  53.                   Fluttertoast.showToast(
  54.                     msg: "Anda menekan inbox",
  55.                     toastLength: Toast.LENGTH_SHORT,
  56.                     gravity: ToastGravity.BOTTOM,
  57.                     fontSize: 15.0,
  58.                   );
  59.                 },
  60.               ),
  61.               ListTile(
  62.                 leading: Icon(Icons.social_distance),
  63.                 title: Text('Social'),
  64.                 onTap: (){
  65.                   //logic menu ketika di tekan
  66.                   Fluttertoast.showToast(
  67.                     msg: "Anda menekan social",
  68.                     toastLength: Toast.LENGTH_SHORT,
  69.                     gravity: ToastGravity.BOTTOM,
  70.                     fontSize: 15.0,
  71.                   );
  72.                 },
  73.               ),
  74.               ListTile(
  75.                 leading: Icon(Icons.help),
  76.                 title: Text('Help'),
  77.                 onTap: (){
  78.                   //logic menu ketika di tekan
  79.                   Fluttertoast.showToast(
  80.                     msg: "Anda menekan help",
  81.                     toastLength: Toast.LENGTH_SHORT,
  82.                     gravity: ToastGravity.BOTTOM,
  83.                     fontSize: 15.0,
  84.                   );
  85.                 },
  86.               )
  87.             ],
  88.           ),
  89.         ),
  90.         body: Center(
  91.           child: Container(
  92.             decoration: BoxDecoration(
  93.               image: DecorationImage(
  94.                 image: AssetImage('images/bg.jpg'),
  95.                 fit: BoxFit.cover,
  96.                 ),
  97.             ),
  98.             padding: EdgeInsets.fromLTRB(50, 100, 50, 50),
  99.             child: Column(
  100.               children: [
  101.                 Icon(
  102.                 Icons.person,
  103.                 size: 150.0,
  104.                 color: Colors.blue,
  105.                 ),
  106.                 Text('Silakan login terlebih dahulu untuk mengakses halaman ini.'),
  107.                 SizedBox(height: 10),
  108.                 SizedBox(height: 10),
  109.                 TextField(
  110.                   decoration: InputDecoration(
  111.                     labelText: 'Username',
  112.                     hintText: 'Masukkan username',
  113.                     prefixIcon: Icon(Icons.person_4),
  114.                     border: OutlineInputBorder(
  115.                       borderRadius: BorderRadius.circular(7.0),
  116.                      
  117.                     ),
  118.                     filled: true,
  119.                     fillColor: Colors.white,
  120.                   ),
  121.                 ),
  122.                 SizedBox(height: 10),
  123.                 TextField(
  124.                   obscureText: true,
  125.                   decoration: InputDecoration(
  126.                     labelText: 'Password',
  127.                     hintText: 'Masukkan Password',
  128.                     prefixIcon: Icon(Icons.password),
  129.                     border: OutlineInputBorder(
  130.                       borderRadius: BorderRadius.circular(7.0),
  131.                      
  132.                     ),
  133.                     filled: true,
  134.                     fillColor: Colors.white,
  135.                   ),
  136.                 ),
  137.                 SizedBox(height: 10),
  138.                 Row(
  139.                   mainAxisAlignment: MainAxisAlignment.center,
  140.                   children: [
  141.                     MaterialButton(
  142.                       onPressed: (){
  143.                       //logic button
  144.                       Fluttertoast.showToast(
  145.                         msg: "Anda berhasil login",
  146.                         toastLength: Toast.LENGTH_SHORT,
  147.                         gravity: ToastGravity.BOTTOM,
  148.                         fontSize: 15.0,
  149.                   );
  150.                     },
  151.                     color: Colors.blue,
  152.                     textColor: Colors.white,
  153.                     child: Text('Login'),
  154.                     minWidth: 100,
  155.                     height: 50,
  156.                     ),
  157.                     SizedBox(width: 10),
  158.                     MaterialButton(
  159.                       onPressed: (){
  160.                       //logic button
  161.                       Fluttertoast.showToast(
  162.                         msg: "Anda menekan tombol batal",
  163.                         toastLength: Toast.LENGTH_SHORT,
  164.                         gravity: ToastGravity.BOTTOM,
  165.                         fontSize: 15.0,
  166.                   );
  167.                     },
  168.                     color: Colors.orange,
  169.                     textColor: Colors.white,
  170.                     child: Text('Batal'),
  171.                     minWidth: 100,
  172.                     height: 50,
  173.                     ),
  174.                   ],
  175.                 ),
  176.               ],
  177.             ),
  178.           ),
  179.         ),
  180.       ),
  181.     );
  182.   }
  183. }
  184.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement