【问题标题】:1 positional argument(s) expected, but 0 found (Flutter)预期 1 个位置参数,但找到 0 个 (Flutter)
【发布时间】:2021-12-18 21:03:48
【问题描述】:

通过教程学习 Bloc 并遇到预期的 1 个位置参数,但发现 0 个错误并且无法确定错误的程度。

    MaterialButton(
                  color: widget.color,
                  child: const Text(
                    'Go to Second Screen',
                      style: TextStyle(color: Colors.white),
                  ),
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (context) => SecondScreen(
                          title: 'Second Screen',
                          color: Colors.redAccent,
                    ),
                    ),
                    );
                  },

【问题讨论】:

  • 到底是哪一行?
  • 请分享错误。

标签: flutter bloc


【解决方案1】:

没有什么能立即引起我的注意,但请尝试使用 Navigator 的以下语法:

Navigator.push(
    context,
    MaterialPageRoute(
        builder: (context) => SecondScreen(
            /* your args */
        ),
    ),
);

【讨论】:

    猜你喜欢
    • 2021-07-27
    • 2021-05-22
    • 2021-11-09
    • 2022-07-25
    • 2021-09-17
    • 2020-11-27
    • 2021-12-11
    • 2021-09-21
    • 2022-07-20
    相关资源
    最近更新 更多