Флаттер баннер перекрывает экран - PullRequest
0 голосов
/ 09 мая 2020
• 1000 код
body: Stack(
                    children: [
                      GestureDetector(
                        onTap: () {
                          percengtageTrigger();
                          API.voteplusQuestion(snapshot.data[index], 0);
                        },
                        child: Container(
                          height: stackHeight * 0.5,
                          width: stackWidth,
                          color: Color(0xffF9D342),
                          child: Column(
                            children: <Widget>[
                              shouldShow
                                  ? Container(
                                      padding: const EdgeInsets.only(
                                          top: 10, right: 10),
                                      height: stackHeight * 0.1,
                                      color: Color(0xffF9D342),
                                      width: double.infinity,
                                      child: Column(
                                        mainAxisSize: MainAxisSize.max,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.end,
                                        children: <Widget>[
                                          Text(
                                            '${percentage1.toStringAsFixed(0)}%',
                                            style: TextStyle(
                                              color: Colors.white,
                                              fontSize: 23,
                                              fontFamily: 'NewsCycle',
                                            ),
                                          ),
                                        ],
                                      ))
                                  : Container(
                                      height: stackHeight * 0.1,
                                color: Color(0xffF9D342),
                                      width: double.infinity,
                                    ),
                              Container(
                                  color: Color(0xffF9D342),
                                  height: stackHeight * 0.4,
                                  width: double.infinity,
                                  child: Column(
                                    children: <Widget>[
                                      Padding(
                                        padding: const EdgeInsets.only(top: 20),
                                        child: Text(
                                          snapshot.data[index].would,
                                          style: TextStyle(
                                            color: Color(0xff292826),
                                            fontSize: 23,
                                            fontWeight: FontWeight.bold,
                                            fontFamily: 'NewsCycle',
                                          ),
                                        ),
                                      ),
                                    ],
                                  )),
                            ],
                          ),
                        ),
                      ),
                      GestureDetector(
                        onTap: () {
                          percengtageTrigger();
                          API.voteplusQuestion(snapshot.data[index], 1);
                        },
                        child: Align(
                          alignment: Alignment.bottomCenter,
                          child: Container(
                            height: stackHeight * 0.5,
                            width: stackWidth,
                            color: Color(0xff292826),
                            child: Column(
                              children: <Widget>[
                                shouldShow
                                    ? Container(
                                        padding: const EdgeInsets.only(
                                            top: 10, right: 10),
                                        height: stackHeight * 0.1,
                                    color: Color(0xff292826),
                                        width: double.infinity,
                                        child: Column(
                                          mainAxisSize: MainAxisSize.max,
                                          crossAxisAlignment:
                                              CrossAxisAlignment.end,
                                          children: <Widget>[
                                            Text(
                                              '${percentage2.toStringAsFixed(0)}%',
                                              style: TextStyle(
                                                color: Colors.white,
                                                fontSize: 23,
                                                fontFamily: 'NewsCycle',
                                              ),
                                            ),
                                          ],
                                        ))
                                    : Container(
                                        height: stackHeight * 0.1,
                                        color: Color(0xff292826),
                                        width: double.infinity,
                                      ),
                                Container(
                                    color: Color(0xff292826),
                                    height: stackHeight * 0.4,
                                    width: double.infinity,
                                    child: Column(
                                      children: <Widget>[
                                        Padding(
                                          padding:
                                              const EdgeInsets.only(top: 40),
                                          child: Text(
                                            snapshot.data[index].rather,
                                            style: TextStyle(
                                              color: Color(0xffF9D342),
                                              fontSize: 23,
                                              fontWeight: FontWeight.bold,
                                              fontFamily: 'NewsCycle',
                                            ),
                                          ),
                                        ),
                                      ],
                                    )),
                              ],
                            ),
                          ),
                        ),
                      ),
                      Align(
                        alignment: Alignment.center,
                        child: Container(
                          width: stackWidth,
                          height: stackHeight * 0.015,
                          color: Colors.white,
                        ),
                      ),
                      Align(
                        alignment: Alignment.center,
                        child: Container(
                            width: stackWidth,
                            height: stackHeight * 0.15,
                            decoration: BoxDecoration(
                              shape: BoxShape.circle,
                              color: Colors.white,
                            ),
                            child: Align(
                              alignment: Alignment.center,
                              child: GestureDetector(
                                onTap: () {
                                  nextQuestion();
                                },
                                child: Text(
                                  "SKIP",
                                  style: TextStyle(
                                      color: Colors.black,
                                      fontFamily: 'FredokaOne',
                                      fontSize: 27),
                                ),
                              ),
                            )),
                      ),
                      Align(
                        alignment: Alignment.bottomCenter,
                        child: Container(
                          child: AdmobBanner(
                            adUnitId: getBannerAdUnitId(),
                            adSize: bannerSize,

                          ),
                        ),
                      ),
                    ],
                  ));

enter image description here

Как вы видите на изображении, он перекрывает серый контейнер. Мне нужны желтые и серые контейнеры того же размера, но поверх баннер № с перекрытием с баннером.

Ответы [ 2 ]

0 голосов
/ 09 мая 2020

Поскольку вы используете стек, дочерние элементы в стеке будут перекрываться. Если вы не хотите, чтобы они перекрывались, вы можете использовать другие виджеты макета, такие как Column или ListView, в соответствии с вашими потребностями. Вы можете обратиться к документации flutter для получения дополнительной информации о виджетах макета.

0 голосов
/ 09 мая 2020

Если ваш контент будет прокручиваться в будущем, я предлагаю вам придерживаться плавающей рекламы и, возможно, добавить широкий серый фон, чтобы закрыть некоторое пространство, как это делают некоторые приложения.

В противном случае, назначьте его небольшой строке внизу (и при необходимости назначьте остальные элементы строкам). Однако объявление займет много места, поэтому не забудьте соответствующим образом отрегулировать другие элементы.

...