type
status
date
slug
summary
tags
category
icon
password
Where does initialization code go?
The main entrypoint in a starter Flutter app is in
lib/main.dart
. The default main
method looks like the following:lib/main.dart
dart
content_copy
Perform any quick initialization (less than a frame or two) before calling
runApp()
, though be aware that the widget tree hasn't been created yet. If you want to perform initialization that takes awhile, such as loading data from disk or over a network, do it in a way that won't block the main UI thread. For more information, check out Asynchronous programming, the FutureBuilder
API, Deferred components, or the Working with long lists cookbook recipe, as appropriate.Every stateful widget has an
initState()
method that is called when the widget is created and added to the widget tree. You can override this method and perform initialization there, though the first line of this method must be super.initState()
.Finally, hot reloading your app does not call
initState
or main
again. Hot restart calls both.先不看了 试着做个app 边做边看看需要啥吧
- Author:ran2323
- URL:https://www.blueif.me//article/16771a79-6e22-80d3-addc-c7baa2e2d1ed
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!