customroute_transition_us 0.0.4 customroute_transition_us: ^0.0.4 copied to clipboard
This package helps to navigate between screens easily. using fadeIn animation
import 'package:flutter/material.dart';
import 'package:customroute_transition_us/customroute_transition_us.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: Text('Material App Bar'),
),
body: Center(
child: Container(
child: Text('Hello World'),
),
),
),
initialRoute: 'page1',
routes: {'page1': (_) => Page1(), 'page2': (_) => Page2()},
);
}
}
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: Text('Paga1'),
backgroundColor: Colors.transparent,
),
body: Center(
child: MaterialButton(
child: Text('Go to page2'),
color: Colors.white,
onPressed: () {
CustomrouteTransitionUs(
child: Page2(), // Page Widget
context: context, // BuildContex
animation: AnimationType.fadeIn, //AnimationType
replacement: true, // Default: false
duration: Duration(milliseconds: 500) //Duration animation
);
},
),
),
);
}
}
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: Text('Paga2'),
backgroundColor: Colors.transparent,
),
body: Center(
child: Text('Page2'),
),
);
}
}