I am triggering a Navigator.pop event and I want to fade out the transition to the page. I have tried Fluro but not I'm not interested in implementing it.
This what I'm doing :
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text("Cart"),
leading: Hero(
tag: "cartIcon",
child: Icon(Icons.shopping_cart, color: Colors.yellow),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.close),
onPressed: () {
Navigator.pop(context);
})
],
),
);
}
No one answered, But i found the solution ,you can do like this using MaterialPageRoute class
CLASS:-
import 'package:flutter/material.dart';
class CustomNavRoute<T> extends MaterialPageRoute<T> {
CustomNavRoute({WidgetBuilder builder, RouteSettings settings})
: super(builder: builder, settings: settings);
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
if (settings.isInitialRoute) return child;
return new FadeTransition(opacity: animation, child: child);
}
}
And Call the class like this :-
Navigator.pushReplacement(context,CustomNavRoute(builder: (context) => IntroScreen()));
Also on push
Navigator.push(context, CustomNavRoute(builder: (context) => LoginSignup()));
This will apply fadein transition on PUSH and POP to page !