Below is the hierarchy of my Widgets. The SingleChildScrollView
and Expanded
were added simply because I wish to get the RefreshIndicator
working.
Scaffold
SingleChildScrollView
Expanded
RefreshIndicator
Column
It was working until I upgrade my flutter recently and caused the following error Incorrect use of ParentDataWidget
I have did a search, the problem seems like because
Expanded
widget can only reside in Column
, Row
or Flex
I put the expanded in any of the widgets above will results in either the refresh not working or another weird error.
Again, my main intention is to have my RefreshIndicator
working inside a Scaffold
.
CodePudding user response:
In Flutter if you use SingleChildScrollView
with Expanded
then it will never work. And if you want to keep both widgets in your code then Wrap your Expanded
with Column
widget. Your Column
widget should be parent widget of your Expanded
widget , not in it's child widget.
CodePudding user response:
But you don't need to use the expend widget for the refresh indicator. Just try with the below code:
Scaffold(
body: new RefreshIndicator(
child: SingleChildScrollView(
child: Center(
child: Column(
children: List.generate(50, (f) => Text("Item $f")),
),
),
),
onRefresh: _refresh,
),
)
//refresh function
Future<Null> _refresh() async{
print('refreshing........');
}