• Flutter命名路由报错-Closure call with mismatched arguments:function 'routes.<anonymous closure>'


    【报错描述】

    Closure call with mismatched arguments: function 'routes.<anonymous closure>'
    Receiver: Closure: (dynamic) => ProductPage
    Tried calling: routes.<anonymous closure>(Instance of 'StatelessElement', arguments: null)
    Found: routes.<anonymous closure>(dynamic) => ProductPage

    //将跳转的页面
    class ProductPage extends StatefulWidget { }

    futter 版本

    Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.18362.900], locale zh-CN)
        • Flutter version 1.17.1 at D:Programsflutter
        • Framework revision f7a6a7906b (6 weeks ago), 2020-05-12 18:39:00 -0700
        • Engine revision 6bc433c6b6
        • Dart version 2.8.2

    【解决方案】

    routes必须要带上参数,否则会报错,如下所示:

    final routes = {
    "/":(content,{arguments}) => Tabs(),
    "/form":(content, {arguments}) => FormPage(),
    "/order":(content, {arguments}) => OrderPage(),
    "/product":(content, {arguments}) => ProductPage(),
    "/search":(content,{arguments}) => SearchPage(arguments:arguments),
    };
  • 相关阅读:
    【convertio.co】免费在线文档转化神器
    成长需熬过“四苦”
    岁月饶过谁
    致我的未来
    一定要相信自己
    奋斗的意义是什么?
    一生一世一双人,半醉半醒半浮生
    逆境中的自己
    怎样才能让人看到你呢
    2020 遇见更好的自己
  • 原文地址:https://www.cnblogs.com/liuyp-ken/p/13173652.html
Copyright © 2020-2023  润新知