Buttons Simple UI with Navigation
import "package:flutter/material.dart";
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Button",
debugShowCheckedModeBanner: false,
theme: ThemeData(
appBarTheme:
const AppBarTheme(backgroundColor: Colors.grey, centerTitle: true),
),
home: const ButtonNavigation(),
);
}
}
class ButtonNavigation extends StatelessWidget {
const ButtonNavigation({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Button Navigation",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SecondPage();
},
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
fixedSize: const Size(200.0, 50.0),
),
child: const Text(
"ElevatedButton",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 20.0),
),
),
const SizedBox(height: 50.0),
OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SecondPage();
},
),
);
},
style: OutlinedButton.styleFrom(
fixedSize: const Size(200.0, 50.0),
),
child: const Text(
"OutlinedButton",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
const SizedBox(height: 50.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SecondPage();
},
),
);
},
style: TextButton.styleFrom(
fixedSize: const Size(200.0, 50.0),
),
child: const Text(
"TextButton",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
),
),
],
),
),
);
}
}
class SecondPage extends StatelessWidget {
const SecondPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Second Page",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
),
body: const Center(
child: Text(
"This is Second Page",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
),
),
);
}
}
Comments
Post a Comment