How to achieve expansion of a widget in both vertical (height) and horizontal (width) direction

前端 未结 4 1236
予麋鹿
予麋鹿 2021-02-18 15:30

The code below lays out a chart in which I\'d need to achieve for the chart to be expanded in both vertical (height) and horizontal (width) direction. The suggested method (e.g.

4条回答
  •  攒了一身酷
    2021-02-18 15:55

    For those who struggled to get gradient together with Material behaviour:

    return new Stack(
      children: [
        new Material(
          elevation: 10,
          borderRadius: new BorderRadius.all(new Radius.circular(30.0)),
          color: Colors.transparent,
          child: new Container(
            constraints: BoxConstraints.expand(height: 50),
          ),
        ),
        new Container(
          constraints: BoxConstraints.expand(height: 50),
          decoration: BoxDecoration(
            borderRadius: new BorderRadius.all(new Radius.circular(30.0)),
            gradient: new LinearGradient(
                colors: [color1, color2],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter),
          ),
          child: new FloatingActionButton.extended(
            backgroundColor: Colors.transparent,
            foregroundColor: Colors.transparent,
            highlightElevation: 0,
            elevation: 0,
            onPressed: () {
              onPressed();
            },
            label: new Text(this.caption,
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.body1),
          ),
        )
      ],
    )
    

提交回复
热议问题