我正在使用PageView
在包含基本RaisedButton
的多个页面之间创建滑动过渡。
但是,在过渡期间该按钮不可单击。相反,当用胶带粘贴屏幕时,它会取消或终止过渡,但是此后需要再次单击。
我的应用如下:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final controller = PageController();
return MaterialApp(
title: "MyApp",
initialRoute: "/",
routes: {
"/": (context) => PageView(
controller: controller,
children: List.generate(100, (_) => MyPage(controller)),
),
},
);
}
}
我的页面如下:
class MyPage extends StatelessWidget {
final PageController controller;
MyPage(this.controller);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
RaisedButton(
onPressed: () {
controller.nextPage(
duration: Duration(milliseconds: 5000),
curve: Curves.ease,
);
},
child: Text("Go to next page"),
),
SizedBox(
width: 200,
height: 200,
child: RaisedButton(
onPressed: () => debugPrint("Button clicked!"),
child: Text("Click me"),
),
)
],
);
}
}
即使正在进行从一页到另一页的转换,是否有办法以某种方式“强制”按下按钮?