I have SingleChildScrollView
which has 1 column and 2 row. I want 2nd row content to be the center of the screen(available space).
If I don’t have SingleChildScrollView
, I can just use Expanded
but here I can’t since it will infinite scroll.
So how can we do this??
Here is the source code and expected image.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Testing'),
),
body: SafeArea(
child: SingleChildScrollView(
child: Container(
color: Colors.grey,
child: Column(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.red),
),
child: Text('First row'),
),
Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.red),
),
child: Text('Second row'),
),
),
],
),
),
),
),
),
);
}
}
2
Answers
Check the answer here. You have to set a fixed height for your column for it. Take note on MediaQuery.of(context).padding.top, if you need to get the height of Android status bar.