I have been trying to set a boolean expression to show or hide a text widget, by getting the true or false statement from the firebase. Here is the code and what i have tried. The firebase line reads Product On-Sale: true (boolean).

```
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
// import 'package:productScreen.dart';
// import 'package:resources/app_data.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StreamBuilder(
          stream: Firestore.instance.collection(appProducts).snapshots(),
          // ignore: missing_return
          builder: (context, snapshot) {
            if (!snapshot.hasData) {
              return Center(
                  child: CircularProgressIndicator(
                      valueColor: AlwaysStoppedAnimation<Color>(
                          Theme.of(context).primaryColor)));
            } else {
              final int dataCount = snapshot.data.documents.length;
              print("data count $dataCount");
              if (dataCount == 0) {
                print('No data Available');
              } else {
                return CustomScrollView(
                  slivers: <Widget>[
                    SliverGrid(
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        mainAxisSpacing: 4.0,
                        crossAxisSpacing: 4.0,
                        childAspectRatio: 0.6,
                      ),
                      delegate: SliverChildBuilderDelegate(
                            (BuildContext context, int index) {
                          final DocumentSnapshot document =
                          snapshot.data.documents[index];

                          return buildProducts(context, index, document);
                        },
                        childCount: dataCount,
                      ),
                    ),
                  ],
                );
              }
            }
          }),
    );
  }
}

// import 'package:pages/productScreen.dart';
class NewProductScreen extends StatefulWidget {
  final String productImage, productTitle, productPrice, productSales;
  final bool  productOnSale;

  const NewProductScreen(
      {Key key,
        this.productImage,
        this.productTitle,
        this.productPrice,
        this.productSales,
        this.productOnSale})
      : super(key: key);

  @override
  _NewProductScreenState createState() => _NewProductScreenState();
}

int indicatorActive = 0;
int _currentIndex = 0;
int selectedSizeIndex = 0;
int selectedColorIndex = 0;

class _NewProductScreenState extends State<NewProductScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: StreamBuilder(
            stream: Firestore.instance.collection(appProducts).snapshots(),
            // ignore: missing_return
            builder: (context, snapshot) {
              if (!snapshot.hasData) {
                return Center(
                    child: CircularProgressIndicator(
                        valueColor: AlwaysStoppedAnimation<Color>(
                            Theme.of(context).primaryColor)));
              } else {
                final int dataCount = snapshot.data.documents.length;
                print("data count $dataCount");
                if (dataCount == 0) {
                  print('No data Available');
                } else {
                  return CustomScrollView(
                    slivers: <Widget>[
                      SliverGrid(
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 2,
                          mainAxisSpacing: 4.0,
                          crossAxisSpacing: 4.0,
                          childAspectRatio: 0.6,
                        ),
                        delegate: SliverChildBuilderDelegate(
                              (BuildContext context, int index) {
                            final DocumentSnapshot document =
                            snapshot.data.documents[index];

                            return buildProducts(context, index, document);
                          },
                          childCount: dataCount,
                        ),
                      )
                    ],
                  );
                }
              }
            }));
  }
}

Widget buildProducts(
    BuildContext context, int index, DocumentSnapshot document) {
  List productImage = document[pImages] as List;
  bool onSales = document[pOnSale];
  onSales = false;

  return GestureDetector(
    onTap: () {
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => NewProductScreen(
                productImage: document[pImages],
                productTitle: document[pTitle],
                productSales: document[pSalesPrice],
                productPrice: document[pPrice],
                productOnSale: document[pOnSale],
              )));
    },
    child: Card(
      elevation: 3,
      child: ClipRRect(
        borderRadius: BorderRadius.circular(5),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Container(
              height: MediaQuery.of(context).size.height / 3.5,
              width: MediaQuery.of(context).size.width / 2,
              decoration: BoxDecoration(
                  image: DecorationImage(image: NetworkImage(productImage[0]))),
            ),
            Expanded(
              flex: 1,
              child: Center(
                child: Container(
                  padding: EdgeInsets.only(top: 5),
                  height: MediaQuery.of(context).size.height / 10,
                  child: Text(
                    "${document[pTitle]}",
                    style: TextStyle(
                      color: Colors.black,
                      fontSize: 15,
                      fontWeight: FontWeight.normal,
                    ),
                  ),
                ),
              ),
            ),
            Expanded(
              flex: 1,
              child: Container(
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.baseline,
                  textBaseline: TextBaseline.alphabetic,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(left: 8),
                      child: Text(
                        "\₦${document[pPrice]}",
                        style: TextStyle(
                          fontSize: 20,
                          fontWeight: FontWeight.normal,
                          color: const Color(0xfff08804),
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 5,
                    ),
                    Text(
                      onSales ? "On Sale" : "",
                      style: TextStyle(
                        fontSize: 10,
                        fontWeight: FontWeight.normal,
                        color: Colors.grey,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    ),
  );
}

// import 'package:resources/app_data.dart';
const String appProducts = "appProducts";

const String pTitle = "Product Title";
const String pPrice = "Product Price";
const String pSalesPrice = "Product Sales Price";
const String pImages = "Product Images";
const String pOnSale = "Product OnSale";

```

So therefore, i want to use a true or false expression to get the text widget to display text or an empty text

```
                  onSales ? "On Sale" : "",

```

![1]: <https://imgur.com/bI9QGDx> "firebase image as requested"