Skip to content

Commit

Permalink
fix: disable animation on replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Sep 29, 2019
1 parent ce00adf commit ae7b124
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/models/theme.dart
Expand Up @@ -36,6 +36,25 @@ class PickerGroupItem<T> {
});
}

// No animation. For replacing route
// TODO: Go back
class StaticRoute extends PageRouteBuilder {
final WidgetBuilder builder;
StaticRoute({this.builder})
: super(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return builder(context);
},
transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return child;
},
);
}

class ThemeModel with ChangeNotifier {
static const storageKey = 'theme';

Expand Down Expand Up @@ -89,14 +108,7 @@ class ThemeModel with ChangeNotifier {
}

pushReplacementRoute(BuildContext context, WidgetBuilder builder) {
switch (theme) {
case AppThemeType.cupertino:
return Navigator.of(context)
.pushReplacement(CupertinoPageRoute(builder: builder));
default:
return Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: builder));
}
return Navigator.of(context).pushReplacement(StaticRoute(builder: builder));
}

Future<bool> showConfirm(BuildContext context, String text) {
Expand Down

0 comments on commit ae7b124

Please sign in to comment.