flutter center of SingleChildScrollView code example

Example: flutter center vertically in singlechildscrollview

ConstrainedBox( //forza il SingleChildScrollView a non shrinkWrappare
	constraints: BoxConstraints(
		minWidth: MediaQuery.of(context).size.width,
		minHeight: MediaQuery.of(context).size.height,
	),
	child: SingleChildScrollView(
		physics: AlwaysScrollableScrollPhysics(),
		child: ConstrainedBox( //forza il Center ad avere l'altezza dello scaffold body
			constraints: BoxConstraints(
				minHeight: MediaQuery.of(context).size.height - Scaffold.of(context).appBarMaxHeight,
			),
			child: Center(
				child: ResponsiveBuilder(
					builder: (context, sizingInformation) {
						return _buildResponsiveLayout(sizingInformation.deviceScreenType);
					}
                ),
			),
		)
	),
)

Tags:

Misc Example