Skip to content

Commit 47b188e

Browse files
authored
Mention that the widget tree is not disposed on exit (flutter#131637)
1 parent f019789 commit 47b188e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/flutter/lib/src/widgets/binding.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,20 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
11521152
///
11531153
/// Initializes the binding using [WidgetsFlutterBinding] if necessary.
11541154
///
1155+
/// ## Application shutdown
1156+
///
1157+
/// This widget tree is not torn down when the application shuts down, because
1158+
/// there is no way to predict when that will happen. For example, a user could
1159+
/// physically remove power from their device, or the application could crash
1160+
/// unexpectedly, or the malware on the device could forcibly terminate the
1161+
/// process.
1162+
///
1163+
/// Applications are responsible for ensuring that they are well-behaved
1164+
/// even in the face of a rapid unscheduled termination.
1165+
///
1166+
/// To artificially cause the entire widget tree to be disposed, consider
1167+
/// calling [runApp] with a widget such as [SizedBox.shrink].
1168+
///
11551169
/// See also:
11561170
///
11571171
/// * [WidgetsBinding.attachRootWidget], which creates the root widget for the

packages/flutter/lib/src/widgets/framework.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,20 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
12381238
/// Implementations of this method should end with a call to the inherited
12391239
/// method, as in `super.dispose()`.
12401240
///
1241+
/// ## Application shutdown
1242+
///
1243+
/// This method is _not_ invoked when the application shuts down, because
1244+
/// there is no way to predict when that will happen. For example, a user's
1245+
/// battery could catch fire, or the user could drop the device into a
1246+
/// swimming pool, or the operating system could unilaterally terminate the
1247+
/// application process due to memory pressure.
1248+
///
1249+
/// Applications are responsible for ensuring that they are well-behaved
1250+
/// even in the face of a rapid unscheduled termination.
1251+
///
1252+
/// To artificially cause the entire widget tree to be disposed, consider
1253+
/// calling [runApp] with a widget such as [SizedBox.shrink].
1254+
///
12411255
/// See also:
12421256
///
12431257
/// * [deactivate], which is called prior to [dispose].

0 commit comments

Comments
 (0)