json_table icon indicating copy to clipboard operation
json_table copied to clipboard

If the table has only Two columns, table can not fit into width

Open avinashyalgonde opened this issue 4 years ago • 4 comments

I want table to be fit to the screen width even if table has less number of columns than expected

avinashyalgonde avatar Jun 30 '20 04:06 avinashyalgonde

Yes its not possible as i kept horizontal scrollview as table wrapper

apgapg avatar Jun 30 '20 04:06 apgapg

@apgapg can you suggest any workaround for this?

sumitbhanushali avatar Aug 13 '20 19:08 sumitbhanushali

Even i myself facing this issue. The issue is Scrollview has no way to center the content if its short in height/width.

Screenshot 2020-08-13 at 11 33 50 PM

apgapg avatar Aug 14 '20 02:08 apgapg

@apgapg currently I am using ConstrainedBox, and MediaQuery to achieve full width

var colCount = 3;
colCount = columns.length < colCount ? columns.length : colCount;
.
.
.
tableHeaderBuilder: (header) {
    return ConstrainedBox(
    constraints: BoxConstraints(
        minWidth: MediaQuery.of(context).size.width / colCount,
    ),
    child: Container(
        padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
        decoration: BoxDecoration(
        border: Border.all(width: 0.5),
        ),
        child: Text(
        header,
        style: TextStyle(
            fontWeight: FontWeight.w700,
            fontSize: 14.0,
            color: Colors.black87,
        ),
        ),
    ),
    );
},

sumitbhanushali avatar Aug 14 '20 09:08 sumitbhanushali