[flutter] replace 'checked mode' with 'debug mode' (#87408)
This commit is contained in:
parent
6f9de0a919
commit
0d3b44e835
@ -48,6 +48,9 @@ Future<void> run(List<String> arguments) async {
|
||||
print('$clock runtimeType in toString...');
|
||||
await verifyNoRuntimeTypeInToString(flutterRoot);
|
||||
|
||||
print('$clock debug mode instead of checked mode...');
|
||||
await verifyNoCheckedMode(flutterRoot);
|
||||
|
||||
print('$clock Unexpected binaries...');
|
||||
await verifyNoBinaries(flutterRoot);
|
||||
|
||||
@ -471,6 +474,29 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Verifies that all instances of "checked mode" have been migrated to "debug mode".
|
||||
Future<void> verifyNoCheckedMode(String workingDirectory) async {
|
||||
final String flutterPackages = path.join(workingDirectory, 'packages');
|
||||
final List<File> files = await _allFiles(flutterPackages, 'dart', minimumMatches: 400)
|
||||
.where((File file) => path.extension(file.path) == '.dart')
|
||||
.toList();
|
||||
final List<String> problems = <String>[];
|
||||
for (final File file in files) {
|
||||
int lineCount = 0;
|
||||
for (final String line in file.readAsLinesSync()) {
|
||||
if (line.toLowerCase().contains('checked mode')) {
|
||||
problems.add('${file.path}:$lineCount uses deprecated "checked mode" instead of "debug mode".');
|
||||
}
|
||||
lineCount += 1;
|
||||
}
|
||||
}
|
||||
if (problems.isNotEmpty) {
|
||||
exitWithError(problems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> verifyNoRuntimeTypeInToString(String workingDirectory) async {
|
||||
final String flutterLib = path.join(workingDirectory, 'packages', 'flutter', 'lib');
|
||||
final Set<String> excludedFiles = <String>{
|
||||
|
@ -533,7 +533,7 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
/// dump this error to the console.
|
||||
///
|
||||
/// If this is true, then the default error handler would only dump this error
|
||||
/// to the console in checked mode. In release mode, the error is ignored.
|
||||
/// to the console in debug mode. In release mode, the error is ignored.
|
||||
///
|
||||
/// This is used by certain exception handlers that catch errors that could be
|
||||
/// triggered by environmental conditions (as opposed to logic errors). For
|
||||
@ -950,7 +950,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
||||
assert(details.exception != null);
|
||||
bool isInDebugMode = false;
|
||||
assert(() {
|
||||
// In checked mode, we ignore the "silent" flag.
|
||||
// In debug mode, we ignore the "silent" flag.
|
||||
isInDebugMode = true;
|
||||
return true;
|
||||
}());
|
||||
|
@ -33,7 +33,7 @@ typedef ServiceExtensionCallback = Future<Map<String, dynamic>> Function(Map<Str
|
||||
/// To use this class in an `on` clause of a mixin, inherit from it and implement
|
||||
/// [initInstances()]. The mixin is guaranteed to only be constructed once in
|
||||
/// the lifetime of the app (more precisely, it will assert if constructed twice
|
||||
/// in checked mode).
|
||||
/// in debug mode).
|
||||
///
|
||||
/// The top-most layer used to write the application will have a concrete class
|
||||
/// that inherits from [BindingBase] and uses all the various [BindingBase]
|
||||
|
@ -660,7 +660,7 @@ class MaterialApp extends StatefulWidget {
|
||||
/// Turns on a [GridPaper] overlay that paints a baseline grid
|
||||
/// Material apps.
|
||||
///
|
||||
/// Only available in checked mode.
|
||||
/// Only available in debug mode.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
@ -29,7 +29,7 @@ abstract class Decoration with Diagnosticable {
|
||||
@override
|
||||
String toStringShort() => objectRuntimeType(this, 'Decoration');
|
||||
|
||||
/// In checked mode, throws an exception if the object is not in a
|
||||
/// In debug mode, throws an exception if the object is not in a
|
||||
/// valid configuration. Otherwise, returns true.
|
||||
///
|
||||
/// This is intended to be used as follows:
|
||||
|
@ -331,7 +331,7 @@ abstract class InlineSpan extends DiagnosticableTree {
|
||||
@protected
|
||||
int? codeUnitAtVisitor(int index, Accumulator offset);
|
||||
|
||||
/// In checked mode, throws an exception if the object is not in a
|
||||
/// In debug mode, throws an exception if the object is not in a
|
||||
/// valid configuration. Otherwise, returns true.
|
||||
///
|
||||
/// This is intended to be used as follows:
|
||||
|
@ -432,7 +432,7 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
|
||||
offset.increment(text != null ? text!.length : 0);
|
||||
}
|
||||
|
||||
/// In checked mode, throws an exception if the object is not in a valid
|
||||
/// In debug mode, throws an exception if the object is not in a valid
|
||||
/// configuration. Otherwise, returns true.
|
||||
///
|
||||
/// This is intended to be used as follows:
|
||||
|
@ -497,7 +497,7 @@ class BoxConstraints extends Constraints {
|
||||
///
|
||||
/// Most of the APIs on BoxConstraints expect the constraints to be
|
||||
/// normalized and have undefined behavior when they are not. In
|
||||
/// checked mode, many of these APIs will assert if the constraints
|
||||
/// debug mode, many of these APIs will assert if the constraints
|
||||
/// are not normalized.
|
||||
@override
|
||||
bool get isNormalized {
|
||||
@ -1951,7 +1951,7 @@ abstract class RenderBox extends RenderObject {
|
||||
return _size!;
|
||||
}
|
||||
Size? _size;
|
||||
/// Setting the size, in checked mode, triggers some analysis of the render box,
|
||||
/// Setting the size, in debug mode, triggers some analysis of the render box,
|
||||
/// as implemented by [debugAssertDoesMeetConstraints], including calling the intrinsic
|
||||
/// sizing methods and checking that they meet certain invariants.
|
||||
@protected
|
||||
|
@ -36,7 +36,7 @@ bool debugPaintLayerBordersEnabled = false;
|
||||
/// [RenderBox.debugHandleEvent].
|
||||
bool debugPaintPointersEnabled = false;
|
||||
|
||||
/// Overlay a rotating set of colors when repainting layers in checked mode.
|
||||
/// Overlay a rotating set of colors when repainting layers in debug mode.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
@ -44,7 +44,7 @@ bool debugPaintPointersEnabled = false;
|
||||
/// areas are being excessively repainted.
|
||||
bool debugRepaintRainbowEnabled = false;
|
||||
|
||||
/// Overlay a rotating set of colors when repainting text in checked mode.
|
||||
/// Overlay a rotating set of colors when repainting text in debug mode.
|
||||
bool debugRepaintTextRainbowEnabled = false;
|
||||
|
||||
/// The current color to overlay when repainting a layer.
|
||||
|
@ -1879,7 +1879,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||
|
||||
/// If a subclass has a "size" (the state controlled by `parentUsesSize`,
|
||||
/// whatever it is in the subclass, e.g. the actual `size` property of
|
||||
/// [RenderBox]), and the subclass verifies that in checked mode this "size"
|
||||
/// [RenderBox]), and the subclass verifies that in debug mode this "size"
|
||||
/// property isn't used when [debugCanParentUseSize] isn't set, then that
|
||||
/// subclass should override [debugResetSize] to reapply the current values of
|
||||
/// [debugCanParentUseSize] to that state.
|
||||
@ -2023,7 +2023,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||
/// See [RepaintBoundary] for more information about how repaint boundaries function.
|
||||
bool get isRepaintBoundary => false;
|
||||
|
||||
/// Called, in checked mode, if [isRepaintBoundary] is true, when either the
|
||||
/// Called, in debug mode, if [isRepaintBoundary] is true, when either the
|
||||
/// this render object or its parent attempt to paint.
|
||||
///
|
||||
/// This can be used to record metrics about whether the node should actually
|
||||
|
@ -3075,7 +3075,7 @@ class RenderMouseRegion extends RenderProxyBox implements MouseTrackerAnnotation
|
||||
/// application and the rest of the application would not repaint.
|
||||
///
|
||||
/// To tell if a particular RenderRepaintBoundary is useful, run your
|
||||
/// application in checked mode, interacting with it in typical ways, and then
|
||||
/// application in debug mode, interacting with it in typical ways, and then
|
||||
/// call [debugDumpRenderTree]. Each RenderRepaintBoundary will include the
|
||||
/// ratio of cases where the repaint boundary was useful vs the cases where it
|
||||
/// was not. These counts can also be inspected programmatically using
|
||||
@ -3237,7 +3237,7 @@ class RenderRepaintBoundary extends RenderProxyBox {
|
||||
return true;
|
||||
}());
|
||||
if (inReleaseMode)
|
||||
properties.add(DiagnosticsNode.message('(run in checked mode to collect repaint boundary statistics)'));
|
||||
properties.add(DiagnosticsNode.message('(run in debug mode to collect repaint boundary statistics)'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
|
||||
}
|
||||
|
||||
/// Throws an exception saying that the object does not support returning
|
||||
/// intrinsic dimensions if, in checked mode, we are not in the
|
||||
/// intrinsic dimensions if, in debug mode, we are not in the
|
||||
/// [RenderObject.debugCheckingIntrinsics] mode.
|
||||
///
|
||||
/// This is used by [computeMinIntrinsicWidth] et al because viewports do not
|
||||
|
@ -245,7 +245,7 @@ typedef InitialRouteListFactory = List<Route<dynamic>> Function(String initialRo
|
||||
/// See also:
|
||||
///
|
||||
/// * [CheckedModeBanner], which displays a [Banner] saying "DEBUG" when
|
||||
/// running in checked mode.
|
||||
/// running in debug mode.
|
||||
/// * [DefaultTextStyle], the text style to apply to descendant [Text] widgets
|
||||
/// without an explicit style.
|
||||
/// * [MediaQuery], which establishes a subtree in which media queries resolve
|
||||
@ -967,9 +967,9 @@ class WidgetsApp extends StatefulWidget {
|
||||
|
||||
/// Turns on an overlay that enables inspecting the widget tree.
|
||||
///
|
||||
/// The inspector is only available in checked mode as it depends on
|
||||
/// The inspector is only available in debug mode as it depends on
|
||||
/// [RenderObject.debugDescribeChildren] which should not be called outside of
|
||||
/// checked mode.
|
||||
/// debug mode.
|
||||
final bool debugShowWidgetInspector;
|
||||
|
||||
/// Builds the widget the [WidgetInspector] uses to switch between view and
|
||||
@ -981,18 +981,18 @@ class WidgetsApp extends StatefulWidget {
|
||||
final InspectorSelectButtonBuilder? inspectorSelectButtonBuilder;
|
||||
|
||||
/// {@template flutter.widgets.widgetsApp.debugShowCheckedModeBanner}
|
||||
/// Turns on a little "DEBUG" banner in checked mode to indicate
|
||||
/// that the app is in checked mode. This is on by default (in
|
||||
/// checked mode), to turn it off, set the constructor argument to
|
||||
/// Turns on a little "DEBUG" banner in debug mode to indicate
|
||||
/// that the app is in debug mode. This is on by default (in
|
||||
/// debug mode), to turn it off, set the constructor argument to
|
||||
/// false. In release mode this has no effect.
|
||||
///
|
||||
/// To get this banner in your application if you're not using
|
||||
/// WidgetsApp, include a [CheckedModeBanner] widget in your app.
|
||||
///
|
||||
/// This banner is intended to deter people from complaining that your
|
||||
/// app is slow when it's in checked mode. In checked mode, Flutter
|
||||
/// app is slow when it's in debug mode. In debug mode, Flutter
|
||||
/// enables a large number of expensive diagnostics to aid in
|
||||
/// development, and so performance in checked mode is not
|
||||
/// development, and so performance in debug mode is not
|
||||
/// representative of what will happen in release mode.
|
||||
/// {@endtemplate}
|
||||
final bool debugShowCheckedModeBanner;
|
||||
|
@ -325,11 +325,11 @@ class Banner extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays a [Banner] saying "DEBUG" when running in checked mode.
|
||||
/// Displays a [Banner] saying "DEBUG" when running in debug mode.
|
||||
/// [MaterialApp] builds one of these by default.
|
||||
/// Does nothing in release mode.
|
||||
class CheckedModeBanner extends StatelessWidget {
|
||||
/// Creates a const checked mode banner.
|
||||
/// Creates a const debug mode banner.
|
||||
const CheckedModeBanner({
|
||||
Key? key,
|
||||
required this.child,
|
||||
|
@ -2087,7 +2087,7 @@ abstract class BuildContext {
|
||||
/// This getter will only return a valid result if [findRenderObject] actually
|
||||
/// returns a [RenderBox]. If [findRenderObject] returns a render object that
|
||||
/// is not a subtype of [RenderBox] (e.g., [RenderView]), this getter will
|
||||
/// throw an exception in checked mode and will return null in release mode.
|
||||
/// throw an exception in debug mode and will return null in release mode.
|
||||
///
|
||||
/// Calling this getter is theoretically relatively expensive (O(N) in the
|
||||
/// depth of the tree), but in practice is usually cheap because the tree
|
||||
|
@ -951,8 +951,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
/// This binding controls time, allowing tests to verify long
|
||||
/// animation sequences without having to execute them in real time.
|
||||
///
|
||||
/// This class assumes it is always run in checked mode (since tests are always
|
||||
/// run in checked mode).
|
||||
/// This class assumes it is always run in debug mode (since tests are always
|
||||
/// run in debug mode).
|
||||
class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
@override
|
||||
void initInstances() {
|
||||
|
@ -393,15 +393,15 @@ const String kDebugWarning = '''
|
||||
/// passed to the `callback`, and that handle will automatically be disposed
|
||||
/// after the callback is finished.
|
||||
///
|
||||
/// Benchmarks must not be run in checked mode, because the performance is not
|
||||
/// Benchmarks must not be run in debug mode, because the performance is not
|
||||
/// representative. To avoid this, this function will print a big message if it
|
||||
/// is run in checked mode. Unit tests of this method pass `mayRunWithAsserts`,
|
||||
/// is run in debug mode. Unit tests of this method pass `mayRunWithAsserts`,
|
||||
/// but it should not be used for actual benchmarking.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// main() async {
|
||||
/// assert(false); // fail in checked mode
|
||||
/// assert(false); // fail in debug mode
|
||||
/// await benchmarkWidgets((WidgetTester tester) async {
|
||||
/// await tester.pumpWidget(MyWidget());
|
||||
/// final Stopwatch timer = Stopwatch()..start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user