dart - 在 Flutter 中,我想在导航到新屏幕后立即调用 for 循环。我把代码放在哪里?
问题描述
基本上我只想在推送到新屏幕后立即调用一些代码。我会把我的代码放在哪里?
解决方案
你可以build
用你的新屏幕小部件的方法来做到这一点。
来自 flutter.io 的示例:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// instead of the next statement, place your code that you want to execute
final wordPair = WordPair.random();
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
title: Text('Welcome to Flutter'),
),
body: Center(
child: Text('Hello World'),
child: Text(wordPair.asPascalCase),
),
),
);
推荐阅读
- sql - oracle并发选择更新和插入
- python - 比较 ML 中不同分类模型的准确性
- javascript - 导入firebase后功能不起作用
- python - 将genymotion中的默认网络摄像头更改为我的真实设备
- javascript - 无法将 base64 图像添加到谷歌云存储
- powershell - 无法使 Powershell 用于 Windows 通知
- python - 当我使用 %load_ext 自动重载时,jupyter 中的 PicklingError
- android - 删除 gradle wrapper 和缓存中的一些文件后,Gradle 同步失败。我应该怎么办?
- websocket - 如何在 warp 中使用 websocket 过滤器发送和接收消息?
- python - 主进程关闭时自动停止python子进程