2

我正在使用 aPageView在包含基本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"),
          ),
        )
      ],
    );
  }
}

即使正在进行从一页到另一页的转换,有没有办法以某种方式“强制”按下按钮?

4

0 回答 0