game/lib/screens/main_wrapper.dart

48 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'battle_screen.dart';
import 'inventory_screen.dart';
class MainWrapper extends StatefulWidget {
const MainWrapper({super.key});
@override
State<MainWrapper> createState() => _MainWrapperState();
}
class _MainWrapperState extends State<MainWrapper> {
int _currentIndex = 0;
final List<Widget> _screens = [
const BattleScreen(),
const InventoryScreen(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: _screens,
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.flash_on),
label: 'Battle',
),
BottomNavigationBarItem(
icon: Icon(Icons.backpack),
label: 'Inventory',
),
],
),
);
}
}