text
stringlengths 1
372
|
|---|
<topic_end>
|
<topic_start>
|
hot reload
|
flutter’s hot reload feature helps you quickly and
|
easily experiment, build UIs, add features, and fix bugs.
|
hot reload works by injecting updated source code files
|
into the running dart virtual machine (vm).
|
after the VM updates classes with the new versions of fields and functions,
|
the flutter framework automatically rebuilds the widget tree,
|
allowing you to quickly view the effects of your changes.
|
<topic_end>
|
<topic_start>
|
how to perform a hot reload
|
to hot reload a flutter app:
|
if you’re working in an IDE/editor that supports flutter’s IDE tools,
|
select save all (cmd-s/ctrl-s),
|
or click the hot reload button on the toolbar.
|
if you’re running the app at the command line using flutter run,
|
enter r in the terminal window.
|
after a successful hot reload operation,
|
you’ll see a message in the console similar to:
|
the app updates to reflect your change,
|
and the current state of the app is preserved.
|
your app continues to execute from where it was prior
|
to run the hot reload command.
|
the code updates and execution continues.
|
what is the difference between hot reload, hot restart,
|
and full restart?
|
flutter web currently supports hot restart but not
|
hot reload.
|
controls for run, run debug, hot reload, and hot restart in android studio
|
a code change has a visible effect only if the modified
|
dart code is run again after the change. specifically,
|
a hot reload causes all the existing widgets to rebuild.
|
only code involved in the rebuilding of the widgets
|
is automatically re-executed. the main() and initState()
|
functions, for example, are not run again.
|
<topic_end>
|
<topic_start>
|
special cases
|
the next sections describe specific scenarios that involve
|
hot reload. in some cases, small changes to the dart code
|
enable you to continue using hot reload for your app.
|
in other cases, a hot restart, or a full restart is needed.
|
<topic_end>
|
<topic_start>
|
an app is killed
|
hot reload can break when the app is killed.
|
for example, if the app was in the background for too long.
|
<topic_end>
|
<topic_start>
|
compilation errors
|
when a code change introduces a compilation error,
|
hot reload generates an error message similar to:
|
in this situation, simply correct the errors on the
|
specified lines of dart code to keep using hot reload.
|
<topic_end>
|
<topic_start>
|
CupertinoTabView’s builder
|
hot reload won’t apply changes made to
|
a builder of a CupertinoTabView.
|
for more information, see issue 43574.
|
<topic_end>
|
<topic_start>
|
enumerated types
|
hot reload doesn’t work when enumerated types are
|
changed to regular classes or regular classes are
|
changed to enumerated types.
|
for example:
|
before the change:
|
<code_start>
|
enum color {
|
red,
|
green,
|
blue,
|
}
|
<code_end>
|
after the change:
|
<code_start>
|
class color {
|
color(this.i, this.j);
|
final int i;
|
final int j;
|
}
|
<code_end>
|
<topic_end>
|
<topic_start>
|
generic types
|
hot reload won’t work when generic type declarations
|
are modified. for example, the following won’t work:
|
before the change:
|
<code_start>
|
class A<T> {
|
t? i;
|
}
|
<code_end>
|
after the change:
|
<code_start>
|
class A<T, v> {
|
t? i;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.