skip to Main Content

I am trying to give a fixed with to my container. I want it to be 50% of the screen. It seem not to be working. Here is my code.

Container(
    width: MediaQuery.of(context).size.width * 0.50,
    padding: EdgeInsets.symmetric(vertical: 15),           
    decoration: BoxDecoration(
       border: Border.all(color: Color.fromARGB(255, 210, 210, 210)),
       borderRadius: BorderRadius.all(Radius.circular(20)),
       color: Colors.grey[100],
    ),
   child Text('50 percent container'),
)

2

Answers


  1. i tried, its working,

    check your statment

    child Text('50 percent container'),
    

    correct it with

    child :Text('50 percent container'),
    
    Login or Signup to reply.
  2.                Container(
                      width: MediaQuery.of(context).size.width * 0.50,
                      padding: const EdgeInsets.symmetric(vertical: 15),
                      decoration: BoxDecoration(
                        border: Border.all(
                            color: const Color.fromARGB(255,210,210,210)),
                        borderRadius:
                            const BorderRadius.all(Radius.circular(20)),
                        color: Colors.grey[100],
                      ),
                      child: const Text('50 percent container'),
                    ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search