Flutter facebook集成未处理的异常:键入&#39; Future <dynamic>&#39;

时间:2018-06-14 11:38:06

标签: facebook dart flutter

使用facebook sdk登录时,我点击facebook按钮时出现此错误。

 flutter: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a 
 subtype of type 'Map<String, Object>'
 [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
type 'Future<dynamic>' is not a subtype of type 'Future<Null>'
#0      FlutterWebviewPlugin.close (package:flutter_webview_plugin/flutter_webview_plugin.dart:73:36)
#1      FacebookConnect.login (package:flutter_facebook_connect/src/flutter_facebook_connect_base.dart:50:34)
<asynchronous suspension>
 #2      _FacebookLoginButtonState._onPressed 
(package:flutter_facebook_connect/src/facebook_login_button.dart:64:61)
<asynchronous suspension>
 #3      _InkResponseState._handleTap 
(package:flutter/src/material/ink_well.dart:494:14)
 #4      _InkResponseState.build.<anonymous closure> 
(package:flutter/src/material/ink_well.dart:549:30)
 #5      GestureRecognizer.invokeCallback 
(package:flutter/src/gestures/recognizer.dart:102:24)
 #6      TapGestureRecognizer._checkUp 
(package:flutter/src/gestures/tap.dart:161:9)
 #7      TapGestureRecognizer.acceptGesture 
(package:flutter/src/gestures/tap.dart:123:7)
 #8      GestureArenaManager.sweep (package:flutter/src/gest<…>
flutter: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a 
subtype of type 'Map<String, Object>'

这是我的代码:

new FacebookLoginButton(
                                appId: appId,
                                  clientSecret: appSecret,
                                scope: [FacebookAuthScope.publicProfile],
                                cookie: false,
                                onConnect: (api, token){
                                  _connect = api;
                                  print(token);
                                },
                              ),

我不确定我在哪里做错了。请让我知道这个错误意味着什么。

这是我的扑动医生总结:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.4.4, on Mac OS X 10.13.4 17E202, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4)
[✓] Android Studio (version 3.1)
[✓] Connected devices (1 available)

• No issues found!

1 个答案:

答案 0 :(得分:0)

我通过禁用dart2模式解决了这个问题。来自android studio: 设置&gt;&GT;语言与框架&gt;&gt;扑。

然后将“在Dart 2.0中运行应用程序”选项设置为“禁用Dart 2”