-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0401d2
commit 899681a
Showing
4 changed files
with
175 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class FadePageRoute extends PageRoute { | ||
FadePageRoute({ | ||
required this.builder, | ||
this.transitionDuration = const Duration(milliseconds: 300), | ||
this.opaque = true, | ||
this.barrierDismissible = false, | ||
this.barrierColor, | ||
this.barrierLabel, | ||
this.maintainState = true, | ||
}); | ||
|
||
final WidgetBuilder builder; | ||
|
||
@override | ||
final Duration transitionDuration; | ||
|
||
@override | ||
final bool opaque; | ||
|
||
@override | ||
final bool barrierDismissible; | ||
|
||
@override | ||
final Color? barrierColor; | ||
|
||
@override | ||
final String? barrierLabel; | ||
|
||
@override | ||
final bool maintainState; | ||
|
||
@override | ||
Widget buildPage(BuildContext context, Animation<double> animation, | ||
Animation<double> secondaryAnimation) => | ||
builder(context); | ||
|
||
@override | ||
Widget buildTransitions(BuildContext context, Animation<double> animation, | ||
Animation<double> secondaryAnimation, Widget child) { | ||
return FadeTransition( | ||
opacity: animation, | ||
child: builder(context), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
// constants | ||
import 'package:flutter_app/constants/color.dart'; | ||
// pages | ||
import 'package:flutter_app/pages/demo/dashLine/index.dart'; | ||
|
||
class RoutePage extends StatefulWidget { | ||
const RoutePage({Key? key}) : super(key: key); | ||
|
||
@override | ||
RoutePageState createState() => RoutePageState(); | ||
} | ||
|
||
class RoutePageState extends State<RoutePage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('自定义路由动画'), | ||
), | ||
body: SingleChildScrollView( | ||
child: Container( | ||
width: double.infinity, | ||
height: 1000, | ||
color: ColorConstant.strongColor.withOpacity(0.3), | ||
margin: const EdgeInsets.symmetric(horizontal: 2), | ||
child: Column( | ||
children: <Widget>[ | ||
InkWell( | ||
onTap: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => const DashLinePage(), | ||
), | ||
); | ||
}, | ||
child: Container( | ||
margin: const EdgeInsets.only(top: 8), | ||
width: 200, | ||
height: 60, | ||
decoration: BoxDecoration( | ||
color: ColorConstant.primaryColor, | ||
), | ||
alignment: Alignment.center, | ||
child: Text( | ||
'去虚线', | ||
style: Theme.of(context).textTheme.headline6, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |