如何更改应用主题中设置的过渡持续时间/速度?
我可以使用主题更改过渡动画MaterialApp
。下面的示例将默认转换替换为FadeTransition
. 使用淡入淡出过渡时感觉很慢,我无法弄清楚如何更改主题中设置的过渡持续时间。
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
final themeData = ThemeData(
pageTransitionsTheme: PageTransitionsTheme(builders: {
TargetPlatform.iOS: FadeTransitionBuilder(),
TargetPlatform.android: FadeTransitionBuilder(),
}),
);
class FadeTransitionBuilder extends PageTransitionsBuilder {
@override
Widget buildTransitions<T>(_, __, animation, ___, child) => FadeTransition(opacity: animation, child: child);
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Mobile',
theme: themeData,
initialRoute: '/',
routes: routes,
);
}
}