Hope you all are well
I just want to know that how can i show data from firebase using ternary operator.
return StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection("AddBooking")
.doc(FirebaseAuth.instance.currentUser!.uid)
.collection("MyBook")
.snapshots(),
builder: (context, snapshot) {
return snapshot.hasData
? ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
DocumentSnapshot dc = snapshot.data!.docs[index];
By using this code i am able to get the data from the firebase it's ok the data is coming and showing and working perfectly. But i want to show the other else part if the data is not present then it should show that part. But i don't know why it's showing a black white page only showing the app bar on that page.
The ternary operator else condition is this:
: Column(
children: [
Padding(
padding: EdgeInsets.fromLTRB(10, 80, 0, 0),
child:
Image.asset("assets/images/lv.png"),
),
Container(
height: 50,
width: 140,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
color: Color.fromARGB(255, 218, 162, 16),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => homeNavBar())); },
child: Center(
child: Text(
"Book a Flight",
style: GoogleFonts.limelight(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
);
all this code is inside this
Widget list() {
And i am calling this in body.
If i put the else condition part in if it show only if mean only this first condition work if data present or not it ignores the second part.
Thanks i advance