📜  如何在 Flutter 中的 initState() 中显示快餐栏 - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:08.255000             🧑  作者: Mango

代码示例1
// We can simply use the WidgetBinding instance to add a callback after the build method is called.. that will show the
// snackbar after the initState is completed and build method is called.

void initState() {
 super.initState();
WidgetsBinding.instance
    .addPostFrameCallback((_) => _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Your message here..")));
}