Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter text inside container

i've created container(2) inside container(1). Can you please help how to add text to the container(1)? Here is my code down below

    return Scaffold(
  body: 
  Padding(
    padding: const EdgeInsets.only(top: 100, left: 30, right: 30, bottom: 25,),
    child: Container(
      height: 300,
      color: Colors.red,
      alignment: Alignment.bottomLeft,
      child: Container(
        width: 360,
        height: 230,
        color: Colors.blue,
        child: Align(
          alignment: Alignment.center,
          child: Text(
            'Car or sport car'
            maxLines: 3,
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 20,
            ),
          ),
        ),
      ),
    ),
  ),
like image 876
Marek Avatar asked Jun 11 '26 01:06

Marek


2 Answers

You just need to put a Column, Row or Stack inside the first Container. Here is an example for your understanding.

return Scaffold(
body: 
Padding(
  padding: const EdgeInsets.only(top: 100, left: 30, right: 30, bottom: 25,),
  child: Container(
    height: 300,
    color: Colors.red,
    alignment: Alignment.bottomLeft,
    child: Column(
      children: [
        Text("Put your Text Here!!!!"),
        Container(
        width: 360,
        height: 230,
        color: Colors.blue,
        child: Align(
          alignment: Alignment.center,
          child: Text(
            'Car or sport car'
            maxLines: 3,
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 20,
            ),
          ),
        ),
      ),]
    ),
  ),
),
like image 73
Aloysius Samuel Avatar answered Jun 13 '26 06:06

Aloysius Samuel


    return Scaffold(
  body: 
  Padding(
    padding: const EdgeInsets.only(top: 100, left: 30, right: 30, bottom: 25,),
    child: Container(
      height: 300,
      color: Colors.red,
      alignment: Alignment.bottomLeft,
      child: Column(children:[
        Text('test'),
        Container(
        width: 360,
        height: 230,
        color: Colors.blue,
        child: Align(
          alignment: Alignment.center,
          child: Text(
            'Car or sport car'
            maxLines: 3,
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 20,
            ),
          ),
        ),
      ),
        ],
      ),
    ),
  ),
like image 20
Jim Avatar answered Jun 13 '26 05:06

Jim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!