mirrored_repositories/flutter_showcase/example/apps/plant_forms/lib
import 'package:flutter/material.dart';

import 'header.dart';

class StackPagesRoute extends PageRouteBuilder {
  final Widget enterPage;
  final List<Widget> previousPages;
  StackPagesRoute({this.previousPages, this.enterPage})
      : super(
          pageBuilder: (
            BuildContext context,
            Animation<double> animation,
            Animation<double> secondaryAnimation,
          ) =>
              enterPage,
          transitionsBuilder: (
            BuildContext context,
            Animation<double> animation,
            Animation<double> secondaryAnimation,
            Widget child,
          ) {
            return Stack(
              overflow: Overflow.clip,
              fit: StackFit.expand,
              children: <Widget>[
                Header(),
                for (int i = 0; i < previousPages.length; i++)
                  SlideTransition(
                    position: new Tween<Offset>(
                      begin: Offset(0, ((previousPages.length - i) * -0.05) + 0.05),
                      end: Offset(0, (previousPages.length - i) * -0.05),
                    ).animate(CurvedAnimation(curve: Curves.easeInCubic, parent: animation)),
                    child: previousPages[i],
                  ),
                SlideTransition(
                  position: new Tween<Offset>(
                    begin: const Offset(0, 1.0),
                    end: Offset.zero,
                  ).animate(animation),
                  child: enterPage,
                )
              ],
            );
          },
        );
}
