Flutter投票中缺少图标按钮

yws3nbqq  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(133)

我有这个民意调查的代码使用flutter_polls.dart依赖,但当我编译代码时,我没有得到图标按钮和底部的文本,这只发生在最后一次民意调查!我不知道为什么我得到了不正确的使用ParentDataWidget错误
[
] 1这是一个图像
` @override Widget build(BuildContext context){ return Stack(children:[ SingleChildScrollView(child:Provider.of(context).isLoading?中心(子项:System. out. println()列(子项:[容器(高度:MediaQuery.of(context).size.height,padding:const EdgeInsets.all(20),child:扩展(子项:ListView.builder(itemCount:pollsList.length,itemBuilder:(BuildContext context,int index){ //final Map<String,dynamic> poll = pollsList[index]; var polaI = pollsList[index];

bool voted = hasVotedFunc(polaI);
                      votedTo = getHasVotedTo(polaI);

                      /* final int days = DateTime(
                    
                  )
                      .difference(DateTime(
                        DateTime.now().year,
                        DateTime.now().month,
                        DateTime.now().day,
                      ))
                      .inDays;
                            */
                      return Provider.of<PollsProvider>(context).isLoading
                          ? Center(child: CircularProgressIndicator())
                          : Container(
                              margin: const EdgeInsets.only(bottom: 20),
                              child: Stack(
                                children: [
                                  FlutterPolls(
                                    // loadingWidget : ,
                                    pollId: polaI.id.toString(),
                                    hasVoted: voted,
                                    userVotedOptionId:
                                        votedTo, //userVotedOptionId.value,
                                    onVoted: (PollOption pollOption,
                                        int newTotalVotes) async {
                                      polaI.options[pollOption.id].votes =
                                          polaI.options[pollOption.id]
                                                  .votes +
                                              1;
                                      // await Future.delayed(const Duration(seconds: 1));
                                      polaI.options[pollOption.id].voters
                                          .add(Provider.of<AuthService>(
                                                  context,
                                                  listen: false)
                                              .currentUser
                                              ?.email);
                                      await Provider.of<PollsProvider>(
                                              context,
                                              listen: false)
                                          .updatePoll(polaI);

                                      return true;
                                    },
                                    // pollEnded: days < 0,
                                    pollTitle: Align(
                                      alignment: Alignment.centerLeft,
                                      child: Text(
                                        polaI.question,
                                        style: const TextStyle(
                                          fontSize: 14,
                                          fontWeight: FontWeight.w600,
                                        ),
                                      ),
                                    ),

                                    pollOptions: List<PollOption>.from(
                                        polaI.options.map((option) {
                                      var a = PollOption(
                                        id: option.id,
                                        title: Text(
                                          option.title,
                                          style: const TextStyle(
                                            fontSize: 14,
                                            fontWeight: FontWeight.w600,
                                          ),
                                        ),
                                        votes: option.votes,
                                      );
                                      return a;
                                    })),
                                    votedPercentageTextStyle:
                                        const TextStyle(
                                      fontSize: 14,
                                      fontWeight: FontWeight.w600,
                                    ),
                                    metaWidget: Row(
                                      children: [
                                        const SizedBox(width: 6),
                                        const Text('•'),
                                        const SizedBox(
                                          width: 6,
                                        ),
                                        IconButton(
                                          icon: Icon(Icons.replay_outlined),
                                          onPressed: () {
                                            DeleteVote(polaI);
                                          },
                                        ),
                                        const SizedBox(
                                          width: 6,
                                        ),
                                      ],
                                    ),
                                  ),
                                  Align(
                                    alignment: Alignment.topRight,
                                    child: PopupMenuButton(
                                      itemBuilder: (context) {
                                        return [
                                          PopupMenuItem(
                                            value: 'Update',
                                            child: Text('Update'),
                                          ),
                                          PopupMenuItem(
                                            value: 'Delete',
                                            child: Text('Delete'),
                                          )
                                        ];
                                      },
                                      onSelected: (String value) {
                                        actionPopUpItemSelected(
                                            value, polaI);
                                      },
                                      child: Icon(Icons.more_vert),
                                    ),
                                  ),
                                ],
                              ),
                            );
                    },
                  ),
                ),
              ),
            ],
          ),
  ),
   Positioned(
      bottom: 20,
      right: 20,
      child: FloatingActionButton(
        onPressed: () {
          Navigator.of(context)
              .push(MaterialPageRoute(builder: (_) => AddPollPage()));
        },
        child: Icon(Icons.add),
      ),
    ),
  
]);

我们的团队

gcmastyq

gcmastyq1#

我相信这个错误来自Expanded小部件被包裹在ListView上。试试看能不能用

相关问题