Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cant fill in color in expanded container – Flutter

I am a beginner in Flutter, why is there no response after I add color to the expanded Container?
But there hasn’t been an error.
All I want to achieve is to fill the entire area with a score with the red color.
What is the problem here?

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:Column(
        children: [
          Container(
            padding: const EdgeInsets.only(top:50,left:20),
            child: Row(
              children: [
                Icon(Icons.menu,size:30,color:Colors.black54),
                Expanded(child: Container(
                  color: Colors.red,
                )),
                Container(
                  margin: const EdgeInsets.only(right:20),
                  width: 50,
                  height: 50,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(10),
                      color: Colors.grey.withOpacity(0.5),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to include height on Container

Expanded(
  child: Container(
    color: Colors.red,
    height: 50, // same as other children
  ),
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading