Advertisement
BlackBoY_

home_page.dart

Jun 19th, 2022
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.51 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:praktikum_pertemuan_10/about_page.dart';
  3. import 'package:praktikum_pertemuan_10/favorite_page.dart';
  4.  
  5. class HomePage extends StatefulWidget {
  6.   @override
  7.   State<HomePage> createState() => _HomePageState();
  8. }
  9.  
  10. class _HomePageState extends State<HomePage> {
  11.   String _minumanFav = "Silahkan Pilih Minuman";
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return Scaffold(
  15.       appBar: AppBar(
  16.         title: Text("Home Page"),
  17.         actions: [
  18.           IconButton(
  19.             icon: Icon(Icons.info_outline),
  20.             onPressed: () => _openAboutPage(),
  21.           ),
  22.         ],
  23.       ),
  24.       body: SafeArea(
  25.         child: Padding(
  26.             padding: const EdgeInsets.all(16),
  27.             child: Text(
  28.               "Minuman Favorit: $_minumanFav",
  29.               style: TextStyle(fontSize: 18),
  30.             )),
  31.       ),
  32.       floatingActionButton: FloatingActionButton(
  33.         child: Icon(Icons.local_drink),
  34.         tooltip: "Pilih Minuman Favorit",
  35.         onPressed: () => _openFavoritPage(),
  36.       ),
  37.     );
  38.   }
  39.  
  40.   void _openAboutPage() {
  41.     Navigator.push(
  42.         context,
  43.         MaterialPageRoute(
  44.             builder: (context) => AboutPage(), fullscreenDialog: true));
  45.   }
  46.  
  47.   void _openFavoritPage() async {
  48.     String _favoriteResponse = await Navigator.push(
  49.         context, MaterialPageRoute(builder: (context) => minumanFav())
  50.     );
  51.     setState(() {
  52.       _minumanFav = _favoriteResponse;
  53.     });
  54.   }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement