Я использую SingleChildScrollView в качестве одного из экранов в моем приложении, ниже приведен код и снимки экрана проблемы:
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
),
body: Container(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 5),
child: Text("Heading",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 10))),
],
),
)),
Expanded(
flex: 8,
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(60),
topRight: Radius.circular(60),
),
child: Container(
padding: EdgeInsets.only(left: 10),
color: Colors.white,
child: SingleChildScrollView(
reverse: true,
scrollDirection: Axis.vertical,
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height,
),
child: Column(
children: <Widget>[
Spacer(
flex: 1,
),
Expanded(
flex: 4,
child: ListView.builder(
scrollDirection: Axis.vertical,
itemCount: 2,
itemBuilder: (context, index) {
return Container(
child: Row(
children: <Widget>[
Container(
child: Expanded(
flex: 8,
child: Text(
"Checkbox",
style: TextStyle(
fontSize:10),
),
),
),
Expanded(
flex: 2,
child: Checkbox(
value:false,
onChanged: (bool value) {
},
)),
],
));
}),
),
Expanded(
flex: 1,
child: Container(
child: Row(
children: <Widget>[
Expanded(
flex: 5,
child: Text(
"Text",
style: TextStyle(
fontSize:
10,
),
),
),
Expanded(
flex: 2,
child: Container(),
),
// Spacer()
],
),
),
),
Expanded(
flex: 1,
child: Container(
child: Row(
children: <Widget>[
Text("Text")
],
))),
Expanded(
flex: 2,
child: Form(
child: Container(
child: Padding(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
child: TextFormField(
minLines: 10,
maxLines: 15,
autocorrect: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey[100],
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0)),
borderSide:
BorderSide(color: Colors.grey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0)),
borderSide:
BorderSide(color: Colors.grey),
),
),
),
),
),
),
),
Expanded(
flex: 2,
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: 50,
width: 100,
child: MaterialButton(
splashColor: Colors.grey,
child: Text(
"Next",
style: TextStyle(
color: Colors.white,
),
),
onPressed: () async {
},
color: Colors.red,
),
),
],
),
),
),
Spacer(flex: 4)
],
),
),
),
)))
],
),
));
}
}
Когда reverse=true
в SCSV, начальная позиция прокрутки, когда экран рендеры выглядят так
and when reverse=false
введите описание изображения здесь
Мне нужна опция reverse = true, чтобы при использовании обратного нажатия прокрутка возвращалась в исходное положение. Но когда экран отображается изначально, он не прокручивается до максимальной степени, то есть запускается посередине. Любая помощь приветствуется.