I've got a PageView.builder
that returns pages. Each has a title and a tag.
I've also got an EditPage
which allows the user to edit the title.
The edited title is updated via PHP on a MySQL database.
Can I get the individual page to automatically update with the new title?
Or do I have to completely rebuild the PageView each time I update the title?
Here's the PageView.builder
code;
class StageBuilder extends StatelessWidget {
final List<SpeakContent> speakcrafts;
StageBuilder(this.speakcrafts);
@override
Widget build(context) {
return PageView.builder(
itemCount: speakcrafts.length,
itemBuilder: (context, int currentIndex) {
return createViewItem(speakcrafts[currentIndex], context);
},
);
}
Widget createViewItem(SpeakContent speakcraft, BuildContext context) {
return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
speakcraft.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
speakcraft.tagname,
),
],
),
],
);
}
}
And here's the code for posting to the PHP/MYSQL database;
Future<String> titleUpdate({String opid, String title}) async {
String upDateUrl;
upDateUrl = "http://example.com?title=" + title;
final response = await get(upDateUrl);
if (response.statusCode == 200) {
print(response.body);
return response.body;
} else
throw Exception('We were not able to successfully update the title');
}