我有一个PageView.builder
返回页面。每个都有一个标题和一个标签。我还有一个EditPage
允许用户编辑标题。编辑后的标题通过 PHP 在 MySQL 数据库上进行更新。
我可以让单个页面自动更新为新标题吗?还是每次更新标题时都必须完全重建 PageView?
这是PageView.builder
代码;
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,
),
],
),
],
);
}
}
这是发布到 PHP/MYSQL 数据库的代码;
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');
}