Flutter命名路由報錯-Closure call with mismatched arguments:function 'routes. '


【報錯描述】

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:\Programs\flutter
    • 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),
};

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM