Nova página através do botão de menu
24/10/2022
Thomas MARQUES
import 'package:flutter/material.dart';
class ProfilePage extends StatelessWidget {
const ProfilePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}
---------------------------------------------
import 'package:flutter/material.dart';
import 'package:flutter_application/home_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.blue),
home: RootPage(),
);
}
}
class RootPage extends StatefulWidget {
const RootPage({Key? key}) : super(key: key);
@override
State<RootPage> createState() => _RootPageState();
}
class _RootPageState extends State<RootPage> {
int currentPage = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('My First App')),
body: const HomePage(),
floatingActionButton: FloatingActionButton(
onPressed: () {
debugPrint('Button pressed');
},
child: const Icon(Icons.add),
),
bottomNavigationBar: NavigationBar(
destinations: const[
NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
NavigationDestination(icon: Icon(Icons.person), label: 'Profile'),
],
onDestinationSelected: (int index){
setState((){
currentPage = index;
});
},
selectedIndex: currentPage,
),
);
}
}