CopyPastor

Detecting plagiarism made easy.

Score: 0.8023157119750977; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-07-14
by diegoveloper

Original Post

Original - Posted on 2019-07-09
by Daniel Allen



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can do it if you know the size of the `footer` and `header` widget and using `LayoutBuilder` widget to get the constraints.
``` @override Widget build(BuildContext newcontext) { return Center( child: Scaffold( body: Container( color: Colors.pink, child: LayoutBuilder( builder: (_, constraints) {
final sizeHeader = 150.0; final sizeFooter = 150.0; final sizeList = 1000.0; final available = constraints.maxHeight - (sizeHeader + sizeFooter);
Widget _buildCenterWidget() { return Container( height: sizeList, color: Colors.green, child: Text("the height of this content could be anything"), ); }
return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Container( height: sizeHeader, color: Colors.orange, child: Text("Header")), available < sizeList ? Expanded( child: _buildCenterWidget(), ) : _buildCenterWidget(), Container( height: sizeFooter, color: Colors.blue, child: Text("Footer")), ], ); }, )), ), ); } ```
So I tried to produce a minimum working bit of code, and ended up with a workable solution (even if all the details aren't ironed out, like the first locked column being of flexible width instead of a fixed width as desired). Hopefully this will help others trying to produce something similar. What's interesting is that the Table construct is needed here, because replacing the TableRow (wrapped by Table) with just a Row causes an overflow error. I would still be interested in understanding why that is since it seems crucial to the layout engine.
``` @override Widget build(BuildContext context) { return ListView( padding: EdgeInsets.all(5.0), children: <Widget>[ Table( children: <TableRow>[ TableRow( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ // first locked column items ], ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ // table header items ], ), Row( children: <Widget>[ // data cells ], ), Row( children: <Widget>[ // data cells ], ), ], ), ), ], ), ], ), ], ); } ```

        
Present in both answers; Present only in the new answer; Present only in the old answer;