Skip to content

Instantly share code, notes, and snippets.

@nemrosim
Created April 20, 2022 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemrosim/c5c61a6bf5e431ecc31451ca0fcf80fb to your computer and use it in GitHub Desktop.
Save nemrosim/c5c61a6bf5e431ecc31451ca0fcf80fb to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/',
routes: {
// When navigating to the "/" route, build the FirstScreen widget.
'/': (context) => const HomePage(),
// When navigating to the "/second" route, build the SecondScreen widget.
'/second': (context) => const Page2(),
},
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Home page'),
),
body: Center(
child: Column(
children: <Widget>[
ElevatedButton(
child: const Text('Simple transition'),
onPressed: () {
Navigator.of(context).pushNamed('/second');
},
),
],
),
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Page 2'),
),
body: const Center(
child: Text(
'Page 2',
style: TextStyle(fontSize: 30),
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment