fluffychat/lib/utils/app_route.dart

36 lines
1.0 KiB
Dart
Raw Normal View History

2021-01-16 12:46:38 +01:00
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
2020-01-01 19:10:13 +01:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AppRoute extends PageRouteBuilder {
static Route defaultRoute(BuildContext context, Widget page) {
2021-01-16 12:46:38 +01:00
return context != null &&
!AdaptivePageLayout.of(context).columnMode(context)
2020-01-01 19:10:13 +01:00
? CupertinoPageRoute(
builder: (BuildContext context) => page,
)
: AppRoute(page);
}
final Widget page;
AppRoute(this.page)
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) =>
page,
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
FadeTransition(
opacity: animation,
child: child,
),
);
}