diff --git a/packages/flutter/lib/src/widgets/interactive_viewer.dart b/packages/flutter/lib/src/widgets/interactive_viewer.dart index 3e21124868..cc410755ab 100644 --- a/packages/flutter/lib/src/widgets/interactive_viewer.dart +++ b/packages/flutter/lib/src/widgets/interactive_viewer.dart @@ -107,6 +107,10 @@ class InteractiveViewer extends StatefulWidget { /// single gesture begun along one axis cannot also cause panning along the /// other axis without stopping and beginning a new gesture. This is a common /// pattern in tables where data is displayed in columns and rows. + /// + /// See also: + /// * [constrained], which has an example of creating a table that uses + /// alignPanAxis. final bool alignPanAxis; /// A margin for the visible boundaries of the child. @@ -146,34 +150,36 @@ class InteractiveViewer extends StatefulWidget { /// /// ```dart /// Widget build(BuildContext context) { - /// const int _rowCount = 20; - /// const int _columnCount = 3; + /// const int _rowCount = 48; + /// const int _columnCount = 6; /// - /// return Scaffold( - /// appBar: AppBar( - /// title: const Text('Pannable Table'), - /// ), - /// body: InteractiveViewer( - /// constrained: false, - /// scaleEnabled: false, - /// child: Table( - /// columnWidths: { - /// for (int column = 0; column < _columnCount; column += 1) - /// column: const FixedColumnWidth(300.0), - /// }, - /// children: [ - /// for (int row = 0; row < _rowCount; row += 1) - /// TableRow( - /// children: [ - /// for (int column = 0; column < _columnCount; column += 1) - /// Container( - /// height: 100, - /// color: row % 2 + column % 2 == 1 ? Colors.red : Colors.green, + /// return InteractiveViewer( + /// alignPanAxis: true, + /// constrained: false, + /// scaleEnabled: false, + /// child: Table( + /// columnWidths: { + /// for (int column = 0; column < _columnCount; column += 1) + /// column: const FixedColumnWidth(200.0), + /// }, + /// children: [ + /// for (int row = 0; row < _rowCount; row += 1) + /// TableRow( + /// children: [ + /// 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'), /// ), - /// ], - /// ), - /// ], - /// ), + /// ), + /// ], + /// ), + /// ], /// ), /// ); /// }