flutter_layout_grid icon indicating copy to clipboard operation
flutter_layout_grid copied to clipboard

Feature request: alignment inside cells.

Open vd3d opened this issue 2 years ago • 1 comments

Hi,

I propose you to add a missing feature which is the alignment inside a cell. currently, if you have multiple cells of different heights then the "content" is aligned on the top. To manage the alignment, we have to play with other components, but it will be way better if we can set up the alignment in the GridPlacement.

Here is an example, on the left you have the text "Volume" which I have aligned with other components, on the right you have the test "USD" which is put on the top of the cell by the LayoutGrid.

image

One idea would be to add some alignment parameters to the GridPlacement. Like this:

AlignmentGeometry? alignment

PS: and thanks for this fantastic layout.

vd3d avatar Nov 11 '23 19:11 vd3d

BTW, I have created a sub-class of GridPlacement that does the job. It is a hack but it works. It is not a clean solution, but still... it do the job ;-)

class LayoutGridPlacement extends GridPlacement { LayoutGridPlacement({ super.key, required Widget child, super.columnStart, super.columnSpan = 1, super.rowStart, super.rowSpan = 1, AlignmentGeometry? alignment, }) : super(child: _getChild(child, alignment)) { //super(child: content); } static Widget _getChild(Widget content, AlignmentGeometry? alignment) { if (alignment == null) alignment = Alignment.centerLeft; return Container(alignment: alignment, child: content); } }

vd3d avatar Nov 11 '23 19:11 vd3d