отображать массив данных firestore в виде трепета на кнопках - PullRequest
0 голосов
/ 27 мая 2020
• 1000

Расположение кнопок примерно такое (снимок экрана)

Мне нравится использовать для этого streamBuilder,

Исходный код,

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();
  }
}

пожалуйста, помогите мне!

Спасибо.

...