When compiling my app, this warning appears inside the container. I've been told to use the expanded widget by wrapping the container and it doesn't work.
return Container(
width: 500.0,
height: 600.0,
margin: const EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
color: color,
boxShadow: const [
BoxShadow(
color: Colors.black,
blurRadius: 0.0,
spreadRadius: 0.0,
offset: Offset(0.0, 0.0), // shadow direction: bottom right
)
],
),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(top: 11.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
logo,
width: 50,
height: 50,
),
const Icon(Icons.favorite, color: Colors.red),
],
),
),
const SizedBox(
height: 10,
),
Text(
companyname,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Text(
role,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(
Icons.location_on,
color: Colors.white,
size: 15,
),
Text(
region,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white),
),
],
),
],
),
),
);
} }
You are working with a fixed size container, if the information is variable it may not always look good, you could change to a wrap like this.
What is happening is that you are giving measurements in pixels within the column that are exceeding the limits of your Container, so it is clear that if you have a 200ml glass of water and you put 250ml of a small part of it, it will spill.
This can be selected with Expanded and Flexible, but from what I see of your application I recommend that you start using a ListView or a CustomScrollView so that you don't have these relative measurement errors.
import 'package:flutter/material.dart';