簡體   English   中英

Flutter 應用程序簡單登錄頁面,我在選擇 acc“&#39;Future 后收到此錯誤<dynamic> &#39; 不是類型 &#39;() =&gt; void&#39; 的子類型&quot;

[英]Flutter app simple login page , iam getting this error after selecting acc "'Future<dynamic>' is not a subtype of type '() => void'"

我正在 Flutter 上構建一個簡單的登錄應用程序,谷歌帳戶選擇彈出窗口,我選擇了帳戶但登錄失敗。

調試控制台

登錄頁面代碼

問題是(我認為)登錄后會發生什么,您的代碼繼續返回loggedInUi 函數的結果。 它有一個構建樹,其中包含 onPressed 中的 ActionChip,您在那里提供一個函數,但您直接調用它(它返回一個 Future,這就是為什么您的錯誤說明了它所說的)

相反,在 onPressed 供應中是這樣的:

() {
 yourFunctionCall(Parameters);
}

這將提供一個僅調用您的函數的 void 函數

輸入'未來<dynamic> ' 不是 'Route 類型的子類型<object> '<div id="text_translate"><p> 我收到以下代碼的以下錯誤。 我試圖導航到下一頁。 我只能導航一次,然后我得到了上面提到的錯誤。 請幫我解決這個問題。 我什至嘗試使用await,但builder不支持await:(BuildContext context)=&gt; SubmitArticles())。</p><pre> class UserSubmitOption extends StatefulWidget { @override _UserSubmitOptionState createState() =&gt; _UserSubmitOptionState(); } class _UserSubmitOptionState extends State&lt;UserSubmitOption&gt; { @override Widget build(BuildContext dynamic) =&gt; MaterialApp( debugShowCheckedModeBanner: false, home:SafeArea ( child: Scaffold( backgroundColor: Colors.indigo[800], resizeToAvoidBottomInset: false, appBar: AppBar( toolbarHeight: 60, backgroundColor: Colors.indigo[900], automaticallyImplyLeading: false, title: Text("What do you want to submit?",style:TextStyle(color:Colors.white,fontWeight:FontWeight.bold)), centerTitle: true, leading: IconButton( icon: Icon(Icons.arrow_back,color:Colors.black,size:25,), onPressed: () =&gt; Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; UserMenu())))), body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: &lt;Widget&gt;[ Padding( padding: const EdgeInsets.all(60.0), child: Center( child: Wrap(spacing: 50, runSpacing: 50.0, children: &lt;Widget&gt;[ GestureDetector( onTap: () { SubmitQuiz(); setState(() { }); }, child: SizedBox( width: 200.0, height: 200.0, child: Card( color: Colors.indigo, borderOnForeground:true, shadowColor: Colors.white, elevation: 20.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0)), child: Center( child: Padding( padding: const EdgeInsets.all(50.0), child: Column( children: &lt;Widget&gt;[ Icon( Icons.vpn_key_outlined,size:60,color:Colors.black, ), // Image.asset("assets/todo.png",width: 64.0,), SizedBox( height: 7.0, ), Text( "Quiz", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 17.0, ), ), SizedBox( height: 5.0, ), ], ), )), ), )), GestureDetector( onTap: () async {Navigator.push(context, MaterialPageRoute ( builder: (BuildContext context) =&gt; SubmitArticles()) );}, child: SizedBox( width: 200.0, height: 200.0, child: Card( color: Colors.indigo, elevation: 20.0, shadowColor:Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0)), child: Center( child: Padding( padding: const EdgeInsets.all(45.0), child: Column( children: &lt;Widget&gt;[ Icon ( Icons.article_outlined,size:60, ), // Image.asset("assets/note.png",width: 64.0,), SizedBox( height: 7.0, ), Text( "Articles", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 17.0), ), SizedBox( height: 5.0, ), ], ), )), ), )), ]), ), ), ], ), ), ))); }</pre></div></object></dynamic>

[英]type 'Future<dynamic>' is not a subtype of type 'Route<Object>'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 Dart Flutter Future Void _CastError(類型“Null”不是類型“List”的子類型<string?> ' 在類型轉換中)錯誤</string?> Flutter:'未來<dynamic> ' 不是類型 'String' 的子類型</dynamic> 顫振:輸入“未來”<dynamic> &#39; 不是 &#39;Widget&#39; 類型的子類型 (flutter_tts) 顫振:輸入“未來”<dynamic> &#39; 不是類型 &#39;Uint8List&#39; 的子類型 未處理的異常:輸入“未來”<dynamic> ' 不是 dart/flutter 中“ProductModel”類型的子類型</dynamic> flutter:引發了另一個異常:類型'Future<dynamic> ' 不是類型 'String' 的子類型</dynamic> 輸入'列表<dynamic> ' 不是類型 'Map 的子類型<dynamic, dynamic> ' 在 flutter 應用程序中</dynamic,></dynamic> Flutter Api 響應列表動態不是未來的子類型 輸入'未來<dynamic> ' 不是類型 'List 的子類型<application> ?</application></dynamic> 輸入'未來<dynamic> ' 不是 'Route 類型的子類型<object> '<div id="text_translate"><p> 我收到以下代碼的以下錯誤。 我試圖導航到下一頁。 我只能導航一次,然后我得到了上面提到的錯誤。 請幫我解決這個問題。 我什至嘗試使用await,但builder不支持await:(BuildContext context)=&gt; SubmitArticles())。</p><pre> class UserSubmitOption extends StatefulWidget { @override _UserSubmitOptionState createState() =&gt; _UserSubmitOptionState(); } class _UserSubmitOptionState extends State&lt;UserSubmitOption&gt; { @override Widget build(BuildContext dynamic) =&gt; MaterialApp( debugShowCheckedModeBanner: false, home:SafeArea ( child: Scaffold( backgroundColor: Colors.indigo[800], resizeToAvoidBottomInset: false, appBar: AppBar( toolbarHeight: 60, backgroundColor: Colors.indigo[900], automaticallyImplyLeading: false, title: Text("What do you want to submit?",style:TextStyle(color:Colors.white,fontWeight:FontWeight.bold)), centerTitle: true, leading: IconButton( icon: Icon(Icons.arrow_back,color:Colors.black,size:25,), onPressed: () =&gt; Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; UserMenu())))), body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: &lt;Widget&gt;[ Padding( padding: const EdgeInsets.all(60.0), child: Center( child: Wrap(spacing: 50, runSpacing: 50.0, children: &lt;Widget&gt;[ GestureDetector( onTap: () { SubmitQuiz(); setState(() { }); }, child: SizedBox( width: 200.0, height: 200.0, child: Card( color: Colors.indigo, borderOnForeground:true, shadowColor: Colors.white, elevation: 20.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0)), child: Center( child: Padding( padding: const EdgeInsets.all(50.0), child: Column( children: &lt;Widget&gt;[ Icon( Icons.vpn_key_outlined,size:60,color:Colors.black, ), // Image.asset("assets/todo.png",width: 64.0,), SizedBox( height: 7.0, ), Text( "Quiz", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 17.0, ), ), SizedBox( height: 5.0, ), ], ), )), ), )), GestureDetector( onTap: () async {Navigator.push(context, MaterialPageRoute ( builder: (BuildContext context) =&gt; SubmitArticles()) );}, child: SizedBox( width: 200.0, height: 200.0, child: Card( color: Colors.indigo, elevation: 20.0, shadowColor:Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0)), child: Center( child: Padding( padding: const EdgeInsets.all(45.0), child: Column( children: &lt;Widget&gt;[ Icon ( Icons.article_outlined,size:60, ), // Image.asset("assets/note.png",width: 64.0,), SizedBox( height: 7.0, ), Text( "Articles", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 17.0), ), SizedBox( height: 5.0, ), ], ), )), ), )), ]), ), ), ], ), ), ))); }</pre></div></object></dynamic>
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM