Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'dua.dart';
- import 'satu.dart';
- void main() {
- runApp(const MyApp());
- }
- class MyApp extends StatefulWidget {
- const MyApp({Key? key}) : super(key: key);
- @override
- MyAppState createState() {
- return MyAppState();
- }
- }
- class MyAppState extends State<MyApp> {
- int idx = 0; //index yang aktif
- void onItemTap(int index) {
- setState(() {
- idx = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- appBar: AppBar(title: const Text("Bottom Nav")),
- body: case2(idx),
- bottomNavigationBar: BottomNavigationBar(
- currentIndex: idx,
- selectedItemColor: Colors.red,
- onTap: onItemTap,
- items: const <BottomNavigationBarItem>[
- BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
- BottomNavigationBarItem(icon: Icon(Icons.school), label: " School"),
- ]),
- ));
- }
- case2(int idx) {
- switch (idx) {
- case 0:
- {
- return const LayarSatu();
- }
- case 1:
- {
- return const LayarDua();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement