wrapWithDefaultView method
Used by runApp to wrap the provided rootWidget in the default View.
The View determines into what FlutterView the app is rendered into. This is currently PlatformDispatcher.implicitView from platformDispatcher. This method will throw a StateError if the PlatformDispatcher.implicitView is null.
The rootWidget widget provided to this method must not already be
wrapped in a View.
Implementation
@override
Widget wrapWithDefaultView(Widget rootWidget) {
assert(
(_currentDartTest != null) != _isDevelopMode,
'_currentDartTest can be null if and only if Hot Restart is enabled',
);
const testLabelEnabled = bool.fromEnvironment('PATROL_TEST_LABEL_ENABLED');
if (!testLabelEnabled || _isDevelopMode) {
return super.wrapWithDefaultView(RepaintBoundary(child: rootWidget));
} else {
return super.wrapWithDefaultView(
Stack(
textDirection: TextDirection.ltr,
children: [
RepaintBoundary(child: rootWidget),
// Prevents crashes when Android activity is resumed (see
// https://github.com/leancodepl/patrol/issues/901)
ExcludeSemantics(
child: Builder(
builder: (context) {
final view = View.of(context);
return Padding(
padding: EdgeInsets.only(
top: MediaQueryData.fromView(view).padding.top + 4,
left: 4,
),
child: IgnorePointer(
child: Text(
_currentDartTest!,
textDirection: TextDirection.ltr,
style: const TextStyle(color: Colors.red),
),
),
);
},
),
),
],
),
);
}
}