I have a Parent page, that contains a PageView
, like this :
class _ParentState extends State<ParentOverview> {
String title = "" ;
List<String> pageTitles = [
"Page 1",
"Page 2",
] ;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Expenses"),
centerTitle: true,
actions: [
Padding(
padding: EdgeInsets.only(right: 20),
child: InkWell(
child: Icon(Icons.refresh),
onTap: (() {
// TODO
}),
),
),
],
),
body: PageView(
scrollDirection: Axis.vertical,
children: [
ChildPage1(),
ChildPage2(),
],
onPageChanged: ((selectedPage) {
setState(() {
title = pageTitles[selectedPage] ;
});
}),
),
);
}
}
The children of PageView
are StatefulWidget
.
This Parent page contains an AppBar
with a button that is used to reload.
When clicking on this button, I want to make a call that reload the data contained inside Page1 and Page2.
How can I achieve that ?
I have been told to use Provider
, but is this the best way to do that ?