routes_transition_jr 0.0.3 routes_transition_jr: ^0.0.3 copied to clipboard
Este es un nuevo paquete generado desde el curdo de flutter. Nos ayuda con la navegacion entre pantallas de manera elegante y fácil.
import 'package:flutter/material.dart';
import 'package:routes_transition_jr/routes_transition_jr.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Material App',
initialRoute: 'page1',
routes: {
'page1': (_) => const Page1(),
'page2': (_) => const Page2(),
},
);
}
}
class Page1 extends StatelessWidget {
const Page1({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Pagina1'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.blue,
body: Center(
child: MaterialButton(
onPressed: () {
RouteTransationJr(
child: const Page2(),
context: context,
duration: const Duration(microseconds: 100),
replacement: true,
animation: AnimationType.fadeIn);
},
color: Colors.white,
child: const Text('Go to'),
),
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Pagina2'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.blueGrey,
body: const Center(
child: Text('Page2'),
),
);
}
}