Use kDebugMode in error_widget.0.dart example (#93408)
This commit is contained in:
parent
355fd23a79
commit
df2781ad18
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user