据我了解和颤振的工作机制,有状态的小部件方法仅在小部件树中第一次构建时被调用一次,并且每次其状态更改或父级重建时都会调用构建方法方法。
bottomNavigationBar: BottomNavigationBar(items: [
BottomNavigationBarItem(icon: new Icon(Icons.home,), title: new Text("HOME", style: new TextStyle(fontSize: 11.0),),),
BottomNavigationBarItem(icon: new Icon(Icons.message,), title: new Text("MESSAGES", style: new TextStyle(fontSize: 11.0),),),
BottomNavigationBarItem(icon: new Icon(Icons.notifications,), title: new Text("NOTIFICATIONS", style: new TextStyle(fontSize: 11.0),),),
BottomNavigationBarItem(icon: new Icon(Icons.assignment,), title: new Text("MENTOR", style: new TextStyle(fontSize: 11.0),),),
BottomNavigationBarItem(icon: new Icon(Icons.account_circle,), title: new Text("PROFILE", style: new TextStyle(fontSize: 11.0),),),
],
onTap: (int index){
setState(() {
_currentActiveIndex = index;
});
},
currentIndex: _currentActiveIndex,
type: BottomNavigationBarType.shifting,
),
body: _getCurrentPage(_currentActiveIndex),
Run Code Online (Sandbox Code Playgroud)
这里的 _currentActiveIndex 是类的状态之一,其中根据 _currentActiveIndex 的值呈现单独的主体小部件。
body: TabBarView(children: <Widget>[ …Run Code Online (Sandbox Code Playgroud) Future<FirebaseUser> login({List<String> userData, var loginCallback, var cancelledCallback,
var errorCallback}) async {
var facebookLogin = FacebookLogin();
var facebookLoginResult = await facebookLogin.logInWithReadPermissions(['email']);
switch (facebookLoginResult.status) {
case FacebookLoginStatus.error:
print("Error");
break;
case FacebookLoginStatus.cancelledByUser:
print("CancelledByUser");
break;
case FacebookLoginStatus.loggedIn:
print("LoggedIn");
break;
}
}
Run Code Online (Sandbox Code Playgroud)
使用flutter_facebook_login插件,它总是抛出此错误。无法弄清楚我要去哪里。这是错误的日志记录。
MissingPluginException(No implementation found for method loginWithReadPermissions on channel com.roughike/flutter_facebook_login)
E/flutter ( 6174): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
E/flutter ( 6174): <asynchronous suspension>
E/flutter ( 6174): #1 FacebookLogin.logInWithReadPermissions (package:flutter_facebook_login/flutter_facebook_login.dart:101:23)
E/flutter ( 6174): <asynchronous suspension>
E/flutter ( 6174): #2 FacebookAuth.login (package:shout_out/util/social_login.dart:26:25)
Run Code Online (Sandbox Code Playgroud) Firestore最近添加了新的新方法FieldValue.arrayUnion(value)和FieldValue.arrayRemove(value),但我在flutter cloud_firestore包中找不到实现。有什么办法可以达到这个结果?
Firestore addUpdate:https ://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array