Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- catatan: di bagian pubspec.yaml di tambahin seperti ini
- dependencies:
- flutter:
- sdk: flutter
- fluttertoast: ^8.2.2
- import 'package:flutter/material.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- void main() {
- runApp(const MainApp());
- }
- class MainApp extends StatelessWidget {
- const MainApp({super.key});
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- appBar: AppBar(
- title: Text('Latihan Widget 2'),
- ),
- drawer: Drawer(
- child: ListView(
- children: [
- UserAccountsDrawerHeader(
- accountName: Text('STMIK ROYAL'),
- accountEmail: Text('yockykisaran466@gmail.com'),
- currentAccountPicture: CircleAvatar(
- backgroundImage: AssetImage('images/profile.jpeg'),
- ),
- ),
- ListTile(
- leading: Icon(Icons.home),
- title: Text('Home'),
- onTap: (){
- //logic menu ketika di tekan
- Fluttertoast.showToast(
- msg: "Anda menekan home",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- ),
- ListTile(
- leading: Icon(Icons.inbox),
- title: Text('Inbox'),
- onTap: (){
- //logic menu ketika di tekan
- Fluttertoast.showToast(
- msg: "Anda menekan inbox",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- ),
- ListTile(
- leading: Icon(Icons.social_distance),
- title: Text('Social'),
- onTap: (){
- //logic menu ketika di tekan
- Fluttertoast.showToast(
- msg: "Anda menekan social",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- ),
- ListTile(
- leading: Icon(Icons.help),
- title: Text('Help'),
- onTap: (){
- //logic menu ketika di tekan
- Fluttertoast.showToast(
- msg: "Anda menekan help",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- )
- ],
- ),
- ),
- body: Center(
- child: Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage('images/bg.jpg'),
- fit: BoxFit.cover,
- ),
- ),
- padding: EdgeInsets.fromLTRB(50, 100, 50, 50),
- child: Column(
- children: [
- Icon(
- Icons.person,
- size: 150.0,
- color: Colors.blue,
- ),
- Text('Silakan login terlebih dahulu untuk mengakses halaman ini.'),
- SizedBox(height: 10),
- SizedBox(height: 10),
- TextField(
- decoration: InputDecoration(
- labelText: 'Username',
- hintText: 'Masukkan username',
- prefixIcon: Icon(Icons.person_4),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(7.0),
- ),
- filled: true,
- fillColor: Colors.white,
- ),
- ),
- SizedBox(height: 10),
- TextField(
- obscureText: true,
- decoration: InputDecoration(
- labelText: 'Password',
- hintText: 'Masukkan Password',
- prefixIcon: Icon(Icons.password),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(7.0),
- ),
- filled: true,
- fillColor: Colors.white,
- ),
- ),
- SizedBox(height: 10),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- MaterialButton(
- onPressed: (){
- //logic button
- Fluttertoast.showToast(
- msg: "Anda berhasil login",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- color: Colors.blue,
- textColor: Colors.white,
- child: Text('Login'),
- minWidth: 100,
- height: 50,
- ),
- SizedBox(width: 10),
- MaterialButton(
- onPressed: (){
- //logic button
- Fluttertoast.showToast(
- msg: "Anda menekan tombol batal",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.BOTTOM,
- fontSize: 15.0,
- );
- },
- color: Colors.orange,
- textColor: Colors.white,
- child: Text('Batal'),
- minWidth: 100,
- height: 50,
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement