如何为水平列表中的每个框添加按钮?

时间:2019-10-20 04:35:21

标签: flutter dart

我找不到为每个图标添加按钮的方法,它们只是显示出来,但是没有任何类型的动作可导航到另一个页面。 这是我的代码,可能我要的很简单,我事先表示歉意,

如果您需要我向您发送其他类型的文件,我没有问题。

小部件upperPart(){

return Stack(
  children: <Widget>[
    ClipPath(
      clipper: UpperClipper(),
      child: Container(

        height: size.getWidthPx(240),
        decoration: BoxDecoration(
          gradient: LinearGradient(

            colors: [colorCurve, colorCurveSecondary],
          ),
        ),
      ),
    ),
    Column(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: size.getWidthPx(36)),

          child: Column(
            children: <Widget>[

              titleWidget(),

              SizedBox(height: size.getWidthPx(10)),

              upperBoxCard(),
            ],
          ),
        ),
        leftAlignText(
            text: "Cercanos a ti",

            leftPadding: size.getWidthPx(16),

            textColor: textPrimaryColor,

            fontSize: 16.0),

        HorizontalList(

          children: <Widget>[

            for  (int i = 0; i < premiumList.length; i)
              propertyCard(premiumList[i],),

          ],
        ),

2 个答案:

答案 0 :(得分:1)

您可以执行以下操作:

HorizontalList(
  children: premiumList.map((item) => propertyCard(item)).toList(),
)

答案 1 :(得分:0)

这是您要求的声明

卡属性卡(财产属性){     退货卡(

    elevation: 4.0,
    margin: EdgeInsets.all(8),
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
    borderOnForeground: true,
    child: Container(
        height: size.getWidthPx(150),
        width: size.getWidthPx(170),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            ClipRRect(
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(12.0),
                    topRight: Radius.circular(12.0)),
                child: Image.asset('assets/${property.image}',
                    fit: BoxFit.fill)),
            SizedBox(height: size.getWidthPx(8)),
            leftAlignText(
                text: property.propertyName,
                leftPadding: size.getWidthPx(8),
                textColor: colorCurve,
                fontSize: 14.0),
            leftAlignText(
                text: property.propertyLocation,
                leftPadding: size.getWidthPx(8),
                textColor: Colors.black,
                fontSize: 14.0),
            SizedBox(height: size.getWidthPx(4)),
            leftAlignText(
                text: property.propertyPrice,
                leftPadding: size.getWidthPx(8),
                textColor: colorCurve,
                fontSize: 14.0,

                fontWeight: FontWeight.w800),
          ],

        )));

}