custom_route_transition_chava 0.0.3 custom_route_transition_chava: ^0.0.3 copied to clipboard
Este es mi primer paquete desarrollado en el curso avanzado de Flutter de Fernando Herrera. Manejo de transiciones entre pantallas.
import 'package:flutter/material.dart';
import 'package:custom_route_transition_chava/custom_route_transition_chava.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
debugShowCheckedModeBanner: false,
initialRoute: 'page1',
routes: {
'page1': (_) => Page1(),
'page2': (_) => Page2(),
},
);
}
}
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page1'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.blue,
body: Center(
child: MaterialButton(
child: Text('Go to Page 2'),
color: Colors.white,
onPressed: () {
RouteTransitions(
context: context,
child: Page2(),
animation: AnimationType.fadein,
duration: Duration(milliseconds: 500),
replacement: true,
);
},
),
),
);
}
}
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page2'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.blueGrey,
body: Center(child: Text('Page 2')),
);
}
}