this is the error msg i get from the consol
======== Exception caught by widgets library ======================================================= The following _CastError was thrown building StreamBuilder<DocumentSnapshot<Map<String, dynamic>>>(dirty, state: _StreamBuilderBaseState<DocumentSnapshot<Map<String, dynamic>>, AsyncSnapshot<DocumentSnapshot<Map<String, dynamic>>>>#3062d): Null check operator used on a null value
class _LandingScreenState extends State<LandingScreen> {
final Stream<DocumentSnapshot<Map<String, dynamic>>> _vendor =
FirebaseFirestore.instance.collection('vendor').doc(FirebaseAuth.instance.currentUser!.uid).snapshots();
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder<DocumentSnapshot<Map<String, dynamic>>>(
stream: _vendor,
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return const Center(child: Text('Something went wrong'));
}
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (!snapshot.data!.exists) {
return const RegistrationScreen();
}
Vendor vendor =
Vendor.fromJson(snapshot.data!.data() as Map<String, dynamic>);
if (vendor.approved == true) {
return const HomeScreen();
}
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 80,
width: 80,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: CachedNetworkImage(
imageUrl: vendor.logo!,
placeholder: (context, url) => Container(
height: 80,
width: 80,
color: Colors.grey,
),
),
),
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Container(
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: const Padding(
padding: EdgeInsets.all(20.0),
child: Text(
'Your application received!\nAdmin will contact you for a confirmation!',
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 25, fontWeight: FontWeight.normal),
),
),
),
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Container(
decoration: const BoxDecoration(
color: Colors.teal,
borderRadius: BorderRadius.all(Radius.circular(50)),
),
child: const Padding(
padding: EdgeInsets.all(20.0),
child: Text(
'blah blah',
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.normal),
),
),
),
),
TextButton(
child: const Text('Sign Out'),
onPressed: () {
FirebaseAuth.instance.signOut().then((value) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (BuildContext context) => LoginScreen(),
),
);
});
},
)
],
)),
);
},
),
);
}
}