custom_route_transitions_jmabar 0.0.3 custom_route_transitions_jmabar: ^0.0.3 copied to clipboard
Page Transitions package from FlutterAdvanced course by Fernando Herrara.
import 'package:flutter/material.dart';
import 'package:custom_route_transitions_jmabar/custom_route_transitions_jmabar.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: 'Material App',
initialRoute: 'page1',
routes: {
'page1': (context) => const Page1(),
'page2': (context) => const Page2(),
},
);
}
}
class Page1 extends StatelessWidget {
const Page1({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(title: const Text('Page 1'), centerTitle: true, backgroundColor: Colors.transparent),
body: Center(
child: MaterialButton(
color: Colors.white,
child: const Text('Go to Page 2'),
onPressed: () {
RouteTransitions(
context: context,
child: const Page2(),
);
}),
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
title: const Text('Page 2'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
body: const Center(
child: Text('Page 2'),
),
);
}
}