'It seems that pthread_join() is not invoked or PTHREAD_ATTR_FLAG_DETACHED is not set Flutter Firebase
I've followed a tutorial regarding 'Flutter Firebase Authentication. I faced many issues due to it being in an old version of firebase, but I migrated and fixed all problems related to the null safety and others. It showed 0 problems/errors.
But on execution, the following error message appears multiple times.
D/libGLESv2(15242): STS_GLApi : DTS is not allowed for Package : com.example.realone
W/libc (15242): It seems that pthread_join() is not invoked or PTHREAD_ATTR_FLAG_DETACHED is not set.
W/libc (15242): pthread tid : 15281
W/libc (15242): pthread start_routine: 0xdeeecce
In the phone, it gives a place where we can write the email and password but when we click on the sign in button it doesn't do anything.
my Sign_in code :
class _LoginPageState extends State<LoginPage> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
late String _email, _password;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(),
body: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
validator: (input) {
if (input!.isEmpty) {
return 'Provide an email';
}
},
decoration: InputDecoration(labelText: 'Email'),
onSaved: (input) => _email = input!,
),
TextFormField(
validator: (input) {
if (input!.length < 6) {
return 'Longer password please';
}
},
decoration: InputDecoration(labelText: 'Password'),
onSaved: (input) => _password = input!,
obscureText: true,
),
ElevatedButton(
onPressed: signIn,
child: Text('Sign in'),
),
],
)),
);
}
void signIn() async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
try {
User? user = (await FirebaseAuth.instance
.signInWithEmailAndPassword(email: _email, password: _password))
.user;
// print(user);
Navigator.push(context,
MaterialPageRoute(builder: (context) => Home(user: user!)));
} catch (e) {
print(e);
}
}
}
}
my home code (the page where the app goes after signing in)
lass Home extends StatelessWidget {
const Home({Key? key, required this.user}) : super(key: key);
final User user;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home ${user.email}'),
),
body: StreamBuilder<DocumentSnapshot>(
stream: FirebaseFirestore.instance
.collection('users')
.doc(user.uid)
.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else if (snapshot.hasData) {
return checkRole(snapshot.data!);
}
return LinearProgressIndicator();
},
),
);
}
Center checkRole(DocumentSnapshot snapshot) {
if (snapshot.data() == null) {
return Center(
child: Text('no data set in the userId document in firestore'),
);
}
if ((snapshot.data() as dynamic)['role'] == 'admin') {
return adminPage(snapshot);
} else {
return userPage(snapshot);
}
}
Center adminPage(DocumentSnapshot snapshot) {
return Center(
child: Text(
'${(snapshot.data() as dynamic)['role']} ${(snapshot.data() as dynamic)['name']}'));
}
Center userPage(DocumentSnapshot snapshot) {
return Center(child: Text((snapshot.data() as dynamic)['name']));
}
}
I have two other files main.dart
and signUp.dart
Would be glad to know the issues in code. Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|