我正在尝试创建一个没有trailing
和leading
小部件的ExpansionTile。我尝试将所有内容放入title
的尝试均未成功,因为那样的话,边缘会有一些填充:
所需效果:
图片#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
内