Создание ExpansionTile только с заголовком - PullRequest
0 голосов
/ 09 июля 2019

Я пытаюсь создать ExpansionTile без trailing и leading виджетов.Мои попытки поместить все в title оказались безуспешными, потому что таким образом по краям есть некоторый отступ:

enter image description here

Желаемый эффект:

enter image description here

Код для рисунка № 1:

 ExpansionTile(
          trailing: Container(
            width: 1,
            height: 1,
          ),
          title: Container(
            height: 85,
            color: Colors.blue.withOpacity(0.2),
            child: Row(
              children: <Widget>[

                // Day of week
                Expanded(
                  child: Row(
                    children: <Widget>[
                      RichText(
                        text: TextSpan(
                          text:
                          capitalize(
                          DateFormat('EEEE',
                              Localizations.localeOf(context).toString()).format(widget.weatherInfos[index].date)),
                          style: TextStyle(
                            color: Colors.white,
                            fontFamily: 'HelveticaNeueLight',
                            fontSize: 14.0,
                            fontWeight: FontWeight.w400,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),


                Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.baseline,
                      textBaseline: TextBaseline.alphabetic,
                      children: <Widget>[

                        // Icon
                        Container(
                          width: 20,
                          height: 20,
                          decoration: BoxDecoration(
                            image: DecorationImage(
                                image: ExactAssetImage('assets/weather-icons/' +
                                    widget.weatherInfos[index].averageIconName  + '.png'),
                                fit: BoxFit.fill
                            ),
                            shape: BoxShape.rectangle,
                          ),
                        ),

                        Expanded(
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.baseline,
                            textBaseline: TextBaseline.alphabetic,
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[

                              // Temperature max
                              RichText(
                                text: TextSpan(
                                  text: widget.weatherInfos[index].tempMax.toString() + "°",
                                  style: TextStyle(
                                    color: Colors.white,
                                    fontFamily: 'HelveticaNeueLight',
                                    fontSize: 20.0,
                                    fontWeight: FontWeight.w400,
                                  ),
                                ),
                              ),


                              // Temperature min
                              Padding(
                                padding: const EdgeInsets.only(left: 10),
                                child: RichText(
                                  text: TextSpan(
                                    text: widget.weatherInfos[index].tempMin.toString() + "°",
                                    style: TextStyle(
                                      color: Colors.white.withOpacity(widget.TextOpacity),
                                      fontFamily: 'HelveticaNeueLight',
                                      fontSize: 16.0,
                                      fontWeight: FontWeight.w400,
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    )
                ),

              ],
            ),
          ),
        );

Код для рисунка № 2:

   Container(
          height: 85,
          color: Colors.blue.withOpacity(0.2),
          child: Row(
            children: <Widget>[

              // Day of week
              Expanded(
                child: Row(
                  children: <Widget>[
                    RichText(
                      text: TextSpan(
                        text:
                        capitalize(
                            DateFormat('EEEE',
                                Localizations.localeOf(context).toString()).format(widget.weatherInfos[index].date)),
                        style: TextStyle(
                          color: Colors.white,
                          fontFamily: 'HelveticaNeueLight',
                          fontSize: 14.0,
                          fontWeight: FontWeight.w400,
                        ),
                      ),
                    ),
                  ],
                ),
              ),


              Expanded(
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.baseline,
                    textBaseline: TextBaseline.alphabetic,
                    children: <Widget>[

                      // Icon
                      Container(
                        width: 20,
                        height: 20,
                        decoration: BoxDecoration(
                          image: DecorationImage(
                              image: ExactAssetImage('assets/weather-icons/' +
                                  widget.weatherInfos[index].averageIconName  + '.png'),
                              fit: BoxFit.fill
                          ),
                          shape: BoxShape.rectangle,
                        ),
                      ),

                      Expanded(
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.baseline,
                          textBaseline: TextBaseline.alphabetic,
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: <Widget>[

                            // Temperature max
                            RichText(
                              text: TextSpan(
                                text: widget.weatherInfos[index].tempMax.toString() + "°",
                                style: TextStyle(
                                  color: Colors.white,
                                  fontFamily: 'HelveticaNeueLight',
                                  fontSize: 20.0,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),
                            ),


                            // Temperature min
                            Padding(
                              padding: const EdgeInsets.only(left: 10),
                              child: RichText(
                                text: TextSpan(
                                  text: widget.weatherInfos[index].tempMin.toString() + "°",
                                  style: TextStyle(
                                    color: Colors.white.withOpacity(widget.TextOpacity),
                                    fontFamily: 'HelveticaNeueLight',
                                    fontSize: 16.0,
                                    fontWeight: FontWeight.w400,
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  )
              ),

            ],
          ),
        )

Все внутри ListView

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...