Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding animation feature to route pages #2

Merged
merged 1 commit into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/helpers/custom_route.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';

class CustomPageTransitionBuilder extends PageTransitionsBuilder{
@override
Widget buildTransitions<T>(
PageRoute<T> route,
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) {
return FadeTransition(
opacity: animation,
child: child,
);
}
}
12 changes: 10 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:weadoreyou/helpers/custom_route.dart';
import './utilities/details.dart';
import './utilities/style.dart';

Expand All @@ -7,6 +8,8 @@ import './screens/puberty.dart';
import './screens/prod.dart';
import './screens/mens.dart';
import './screens/health.dart';
import 'screens/start.dart';
import './helpers/custom_route.dart';

void main() => runApp(MyApp());

Expand All @@ -17,15 +20,20 @@ class MyApp extends StatelessWidget {
title: 'We Adore You',
home: HomePage(),
debugShowCheckedModeBanner: false,
theme: ThemeData(fontFamily: 'Poppins'),
theme: ThemeData(
fontFamily: 'Poppins',
pageTransitionsTheme: PageTransitionsTheme(builders: {
TargetPlatform.android: CustomPageTransitionBuilder(),
TargetPlatform.iOS: CustomPageTransitionBuilder(),
},),
),
initialRoute: '/',
routes: {
'/start': (BuildContext context) => Start(),
'/puberty': (BuildContext context) => Puberty(),
'/mens': (BuildContext context) => Mens(),
'/prod': (BuildContext context) => Prod(),
'/health': (BuildContext context) => Health(),

},
);
}
Expand Down