'The ParentDataWidget Positioned wants to apply ParentData of type StackParentData to a RenderObject

What is the error on this and what does it mean? i am trying to fix some overflow error on this but cant understand what does it mean

Error Message

The ownership chain for the RenderObject that received the incompatible parent data was: DecoratedBox ← Container ← Positioned ← SizedBox ← Row ← Padding ← DecoratedBox ← ConstrainedBox ← Padding ← Container ← ⋯

class AbandonedMoney extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Container(
          width: double.infinity,
          margin: EdgeInsets.only(bottom: 1, top: 30, left: 20, right: 20),
          padding: EdgeInsets.symmetric(
            horizontal: 20,
            vertical: 20,
          ),
          decoration: BoxDecoration(
            color: Color(0xFFF6692F),
            borderRadius: BorderRadius.circular(20),
          ),
          child: Row(
            children: [
              SizedBox(
                width: 58,
                height: 60,
                child: Positioned(
                  child: Container(
                      padding: EdgeInsets.all(10),
                      decoration: BoxDecoration(
                        color: Colors.white24,
                        borderRadius: BorderRadius.circular(15),
                      ),
                      child: SvgPicture.asset("Assets/svg/handmoney.svg")),
                ),
              ),
              Column(
                children: [
                  Padding(
                    padding: EdgeInsets.only(right: 70),
                    child: AutoSizeText(
                      "\$1122k",
                      style: TextStyle(
                        color: Colors.white,
                        fontFamily: 'Circular Std',
                        fontSize: 30,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                  AutoSizeText(
                    "Abandoned from 1396 carts",
                    style: TextStyle(
                      color: Colors.white60,
                      fontFamily: 'Circular Std',
                      fontSize: 12,
                      fontWeight: FontWeight.normal,
                    ),
                  ),
                ],
              ),
              Container(
                padding: EdgeInsets.all(8),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(10),
                ),
                child: Text(
                  "- 948%",
                  style: TextStyle(
                    color: Color(0xFFF6692F),
                    fontFamily: 'Circular Std',
                    fontSize: 12,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}

I am trying to fix the text which is in the center of the container and the below text both text should start on certain point and if id add more number the text position is changing thats the issue



Solution 1:[1]

Issue is coming because from Stack. Its children require positional widget. In your case, you have one inside Row which is not suitable. You can check more about Stack

You don't need to use Stack the approach you are using. Therefore, Positinoned widget won't be needed. I have included comment where I've modified and play with this and encourage checking about constraints.


class AbandonedMoney extends StatelessWidget {
  const AbandonedMoney({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.only(bottom: 1, top: 30, left: 20, right: 20),
      padding: const EdgeInsets.symmetric(
        horizontal: 20,
        vertical: 20,
      ),
      decoration: BoxDecoration(
        color: const Color(0xFFF6692F),
        borderRadius: BorderRadius.circular(20),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.spaceBetween, //play with this
        children: [
          SizedBox(
            width: 58,
            height: 60,
            child: Container(
              padding: EdgeInsets.all(10),
              decoration: BoxDecoration(
                color: Colors.white24,
                borderRadius: BorderRadius.circular(15),
              ),
              // child: SvgPicture.asset("Assets/svg/handmoney.svg"),
            ),
          ),
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.start, //play with this
            crossAxisAlignment: CrossAxisAlignment.center, //play with this
            children: const [
              Text(
                "\$1122k",
                textAlign: TextAlign.center, //play with this
                style: TextStyle(
                  color: Colors.white,
                  fontFamily: 'Circular Std',
                  fontSize: 30,
                  fontWeight: FontWeight.bold,
                ),
              ),
              Text(
                "Abandoned from 1396 carts",
                textAlign: TextAlign.center, //play with this
                style: TextStyle(
                  color: Colors.white60,
                  fontFamily: 'Circular Std',
                  fontSize: 12,
                  fontWeight: FontWeight.normal,
                ),
              ),
            ],
          ),
          Container(
            padding: EdgeInsets.all(8),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(10),
            ),
            child: Text(
              "- 948%",
              style: TextStyle(
                color: Color(0xFFF6692F),
                fontFamily: 'Circular Std',
                fontSize: 12,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Sources

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

Source: Stack Overflow

Solution Source
Solution 1