'Row Overflow in Flutter

  SizedBox(
                    height: size.height * 0.5,
                    child: Row(
                      children: [
                        Expanded(
                          flex: 2,
                          child: SizedBox(
                            height: size.height * 0.5,
                            child: Card(
                              margin: const EdgeInsets.fromLTRB(20, 0, 5, 10),
                              key: _cardKey,
                              shape: const RoundedRectangleBorder(
                                borderRadius: BorderRadius.all(
                                  Radius.circular(10),
                                ),
                              ),
                              elevation: 10.0,
                              color: Colors.white,
                              child: Padding(
                                padding:
                                    const EdgeInsets.only(left: 10, top: 10),
                                child: Row(
                                  crossAxisAlignment:
                                  CrossAxisAlignment.stretch,
                                  children: _numbers.map((int number) {
                                    counter++;
                                    return CustomPaint(
                                      painter: BarPainter(
                                        width: cardSize!.width / sample,
                                        height: number,
                                        index: counter,
                                        size: cardSize,
                                      ),
                                    );
                                  }).toList(),
                                ),
                              ),
                            ),
                          ),
                        ),

I want the Row to be constrained inside the card, but it overflows, can anyone suggest why is this happening? Here is a picture of the problem.

enter image description here



Sources

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

Source: Stack Overflow

Solution Source