I have been struggling with this for a while guys.
My flutter_facebook_package is successfully hooked up with the app, but for some reason fbLogin.logInWithReadPermissions
shows:
[dart] The method 'logInWithReadPermissions' isn't defined for the class 'FacebookLogin'
Did I miss anything with getting the package or importing something more?
import 'package:flutter/material.dart';
//facebook signUp
import 'package:flutter_facebook_login/flutter_facebook_login.dart';
import 'package:firebase_auth/firebase_auth.dart';
class FacebookLogin extends StatefulWidget {
@override
_FacebookLoginState createState() => _FacebookLoginState();
}
class _FacebookLoginState extends State<FacebookLogin> {
FacebookLogin fbLogin = new FacebookLogin();
@override
Widget build(BuildContext context) {
return
Container(
height: 40.0,
child: Material(
borderRadius: BorderRadius.circular(20.0),
shadowColor: Colors.blueAccent,
color: Color.fromARGB(255, 76, 112, 166),
elevation: 7.0,
child: GestureDetector(
onTap: () {
fbLogin.logInWithReadPermissions(['email', 'public_profile']).then((result) {
switch(result.status) {
case FacebookLoginStatus.loggedIn:
FirebaseAuth.instance.signInWithFacebook(
accessToken: result.accessToken.token
).then((signedInUser) {
print('Sighned in as ${signedInUser.displayName}');
Navigator.of(context).pushReplacementNamed('/homepage');
}).catchError((e) {
print(e);
});
}
})
.catchError((e) {
print(e);
});
},
child: Center(
child: Text('Log in with facebook',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontFamily: 'Monserrat'
)),
),
),
),
);
}
}
Just replace fbLogin.logInWithReadPermissions(['email']);
with fbLogin.logIn(['email']);
If you are using flutter_facebook_login
3.0.0, they have removed deprecated method loginWithPublishPermissions
and renamed loginWithReadPermission
to login
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With