'Undefined name 'users' flutter dart
I'd like to define variable 'users' but I get into an error
I was learning to make display profile on flutter like regular basic apps but it can't auto generate it
this is my full code of Profile.dart
part of 'views.dart';
class Profile extends StatefulWidget {
const Profile({Key? key}) : super(key: key);
@override
_ProfileState createState() => _ProfileState();
}
class _ProfileState extends State<Profile> {
final FirebaseAuth auth = FirebaseAuth.instance;
Future getUser() async {
await FirebaseFirestore.instance.collection('Users').doc(auth.currentUser!.uid).get().then((DocumentSnapshot doc) async {
final Users users = Users (
doc['uid'],
doc['photo'],
doc['name'],
doc['phone'],
doc['email'],
doc['password'],
doc['created'],
doc['updated'],
doc['entered'],
doc['left']
);
return ProfileView(users: users);
});
}
@override
void initState() {
super.initState();
getUser();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: getUser(),
builder: (context, snapshot) {
if (snapshot.hasError || !snapshot.hasData) {
return const Center(child: Text("No internet connection"));
}
else if (snapshot.connectionState == ConnectionState.waiting) {
return Activity.loading();
}
return ProfileView(users: users);
}
);
}
}
I was planning to return the display to ProfileView.dart that contains a lot of widgets on there
views.dart & widgets.dart just packages only
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
