跳到主要内容

flutter 学习笔记

· 阅读需 1 分钟
Yangbingrui
Front End Engineer @ grg

怎么在页面返回时,通知前一个页面刷新数据

// 主动返回
Navigator.pop(context, result);

// 被动返回
@override
Widget build(BuildContext context) {
return WillPopScope( // 添加 WillPopScope 来处理返回操作
onWillPop: () async {
Navigator.pop(context, true); // 返回时通知需要刷新
return false; // 返回 false 因为我们已经手动处理了 pop
},
child: Scaffold(
// ... 现有的 Scaffold 内容
),
);
}

11/26

· 阅读需 1 分钟
Yangbingrui
Front End Engineer @ grg

renderer.capabilities.getMaxAnisotropy