constrained property
Whether the normal size constraints at this point in the widget tree are applied to the child.
If set to false, then the child will be given infinite constraints. This is often useful when a child should be bigger than the InteractiveViewer.
For example, for a child which is bigger than the viewport but can be panned to reveal parts that were initially offscreen, constrained must be set to false to allow it to size itself properly. If constrained is true and the child can only size itself to the viewport, then areas initially outside of the viewport will not be able to receive user interaction events. If experiencing regions of the child that are not receptive to user gestures, make sure constrained is false and the child is sized properly.
Defaults to true.
{@tool dartpad --template=stateless_widget_scaffold}
This example shows how to create a pannable table. Because the table is
larger than the entire screen, setting constrained
to false is necessary
to allow it to be drawn to its full size. The parts of the table that
exceed the screen size can then be panned into view.
Widget build(BuildContext context) {
const int _rowCount = 48;
const int _columnCount = 6;
return InteractiveViewer(
alignPanAxis: true,
constrained: false,
scaleEnabled: false,
child: Table(
columnWidths: <int, TableColumnWidth>{
for (int column = 0; column < _columnCount; column += 1)
column: const FixedColumnWidth(200.0),
},
children: <TableRow>[
for (int row = 0; row < _rowCount; row += 1)
TableRow(
children: <Widget>[
for (int column = 0; column < _columnCount; column += 1)
Container(
height: 26,
color: row % 2 + column % 2 == 1
? Colors.white
: Colors.grey.withOpacity(0.1),
child: Align(
alignment: Alignment.centerLeft,
child: Text('$row x $column'),
),
),
],
),
],
),
);
}
{@end-tool}
Implementation
final bool constrained;