Use kDebugMode in error_widget.0.dart example (#93408)

This commit is contained in:
Ahmed Masoud 2022-04-12 03:04:06 +02:00 committed by GitHub
parent 355fd23a79
commit df2781ad18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,21 +4,15 @@
// Flutter code sample for ErrorWidget
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
// Set the ErrorWidget's builder before the app is started.
ErrorWidget.builder = (FlutterErrorDetails details) {
// This is how to tell if you're in debug mode: Assertions are only executed in
// debug mode.
bool inDebug = false;
assert(() {
inDebug = true;
return true;
}());
// If we're in debug mode, use the normal error widget which shows the error
// message:
if (inDebug) {
if (kDebugMode) {
return ErrorWidget(details.exception);
}
// In release builds, show a yellow-on-blue message instead: