body method
Provide the body of the webpage
Implementation
@override
Widget body(BuildContext context) {
//
StackWidgetProperties? stackProps;
Widget? _child;
try {
/// Retrieve the main content if any.
_child = scrollChild(context);
} catch (ex, stack) {
_child = null;
FlutterError.reportError(FlutterErrorDetails(
exception: ex,
stack: stack,
library: 'webpage_base.dart',
context: ErrorDescription('_child = scrollChild(context)'),
));
// Make the error known if under development.
if (App.inDebugger) {
rethrow;
}
}
Widget? _overlay;
///
stackProps = screenOverlay(context);
/// Display the overlay if it exists
if (_child == null) {
_child = stackProps?.child;
} else {
_overlay = stackProps?.child;
}
/// If there is indeed no content to be displayed.
if (_child == null) {
//
final FlutterErrorDetails details = FlutterErrorDetails(
exception: Exception('No web content was supplied?'),
library: 'webpage_base.dart',
context: ErrorDescription(
"Please, look to the 'controller' for providing content."),
);
FlutterError.reportError(details);
// Notify the developer. Leave an 'empty screen' in production.
if (App.inDebugger) {
_child = ErrorWidget.builder(details);
}
} else {
//
_child = SingleChildScrollView(
scrollDirection: scrollDirection ?? Axis.vertical,
reverse: reverse ?? false,
padding: padding,
primary: false,
physics: physics ?? const ClampingScrollPhysics(),
controller: scrollController,
dragStartBehavior: dragStartBehavior ?? DragStartBehavior.start,
clipBehavior: clipBehavior ?? Clip.hardEdge,
keyboardDismissBehavior:
keyboardDismissBehavior ?? ScrollViewKeyboardDismissBehavior.manual,
child: _child,
);
///
if (_overlay != null) {
_child = Stack(
alignment: stackProps?.alignment ?? AlignmentDirectional.topStart,
textDirection: stackProps?.textDirection,
fit: stackProps?.fit ?? StackFit.loose,
clipBehavior: stackProps?.clipBehavior ?? Clip.hardEdge,
children: [
_child,
_overlay,
],
);
}
}
return WebScrollbar(
color: Colors.blueGrey,
backgroundColor: Colors.blueGrey.withOpacity(0.3),
width: 16,
heightFraction: 0.3,
controller: scrollController,
child: _child ?? const SizedBox(),
);
}