0

How to place the "question mark" at center of row? Expected result is "?" are all at center regardless of the values on left/right.

Expected Result

      body: ListView.builder(
      itemCount: testList.length,
      itemBuilder: (BuildContext context, int index) {
        return Card(
          child: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Container(
                    color: Colors.green,
                    child: Text(testList[index].n1.toString(), style: TextStyle(fontSize: 80,)),
                  ),
                  Container(
                    color: Colors.red,
                    child: Text(testList[index].x, style: TextStyle(fontSize: 80,)),
                  ),
                  Container(
                    color: Colors.green,
                    child: Text(testList[index].n2.toString(), style: TextStyle(fontSize: 80, )),
                  ),
                ],
              ),
              Text('>'),
              Text('<'),
              Text('='), //
            ],
          ),
        );
      }),

1 Answer 1

2

You can use row and Expanded with flex widget to achieve your desire output.

Following minimal code help you more.

Card(
      child: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Expanded(
                flex: 1,
                child: Row(
                  children: [
                    Expanded(child: Container()),
                    Container(
                      color: Colors.green,
                      child: Text('10',
                          style: TextStyle(
                            fontSize: 80,
                          )),
                    ),
                  ],
                ),
              ),
              Container(
                color: Colors.red,
                child: Text("?",
                    style: TextStyle(
                      fontSize: 80,
                    )),
              ),
              Expanded(
                flex: 1,
                child: Row(
                  children: [
                    Container(
                      color: Colors.green,
                      child: Text('100',
                          style: TextStyle(
                            fontSize: 80,
                          )),
                    ),
                    Expanded(child: Container()),
                  ],
                ),
              ),
            ],
          ),
          Text('>'),
          Text('<'),
          Text('='), //
        ],
      ),
    )
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. middle/center should have a flex =1
this will work without even flex i think. flex used when you want to divide expanded widget's size in different ratio. for example if you give any expanded widget flex:2 and other's flex:1 then first widget will take double space then other one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.