'How do I set the size of a container in a expanded stack?

I Have the following build method

  @override
  Widget build(BuildContext context) {
    return Container(
      width: widget.size.width,
      height: widget.size.height,
      clipBehavior: Clip.hardEdge,
      decoration: BoxDecoration(
        color: widget.backgroundColor,
        borderRadius: const BorderRadius.all(
          Radius.circular(30),
        ),
      ),
      child: Stack(
        fit: StackFit.expand,
        children: [
          Container(
            height: 5,
            color: widget.glossColor,
          ),
          Container(
            height: 10,
            color: widget.glossColor2,
          ),
        ],
      ),
    );
  }

I want the change the height of the container with the gloss color. But it's height and width are always the same as the outer container doing it like this.

I want to make it so that the stack has the same size as the outer container and the content can never be bigger and scales down to fit the stack. But also I want to be able to control the height and width of the container inside the stack.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source