Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:praktikum_pertemuan_10/about_page.dart';
- import 'package:praktikum_pertemuan_10/favorite_page.dart';
- class HomePage extends StatefulWidget {
- @override
- State<HomePage> createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- String _minumanFav = "Silahkan Pilih Minuman";
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Home Page"),
- actions: [
- IconButton(
- icon: Icon(Icons.info_outline),
- onPressed: () => _openAboutPage(),
- ),
- ],
- ),
- body: SafeArea(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Text(
- "Minuman Favorit: $_minumanFav",
- style: TextStyle(fontSize: 18),
- )),
- ),
- floatingActionButton: FloatingActionButton(
- child: Icon(Icons.local_drink),
- tooltip: "Pilih Minuman Favorit",
- onPressed: () => _openFavoritPage(),
- ),
- );
- }
- void _openAboutPage() {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AboutPage(), fullscreenDialog: true));
- }
- void _openFavoritPage() async {
- String _favoriteResponse = await Navigator.push(
- context, MaterialPageRoute(builder: (context) => minumanFav())
- );
- setState(() {
- _minumanFav = _favoriteResponse;
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement