0

I want a show three buttons in my flutter app, and its names had on the firestore database array list document,

buttons
  0: "country 1"
  1: "country 2"
  2: "country 3"

database like this (screenshot)

Button arrange like this (screenshot)

I like to use streamBuilder for this,

Source code,

class _FrontPageState extends State<FrontPage> {
  final databaseReference = Firestore.instance;

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: databaseReference.collection('Collection').snapshots(),
      builder: (context, snapshot) {
        if (snapshot.hasData) 
          return Container(
            height: 200,
            child: SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              child: Row(
                children: specialWidget(snapshot),
              ),
            ),
          );
        }
      },
    );
  }

  specialWidget(AsyncSnapshot<QuerySnapshot> snapshot) {
    return snapshot.data.documents.map((listItem) {
      return Viewer(
        imagePath: listItem['imageUrl'],
        title: listItem['recipe name'],
        likes: listItem['likes'],
        // buttons: ??,         <<<<<<<<<<<<<<<< that is the problem point
      );
    }).toList();
  }
}

please help me!

Thank you.

Geethma
  • 25
  • 2
  • 5

0 Answers0