buildLogPanel method
Implementation
Widget buildLogPanel(
Widget child, {
bool showLogPanel = true,
double? minHeight,
}) {
if (!showLogPanel) return child;
return LayoutBuilder(builder: (context, constraints) {
child = MediaQuery.removePadding(
context: context,
removeBottom: true,
child: child,
);
minHeight = minHeight ?? (constraints.maxHeight / 3);
_maxHeight = _maxHeight ?? minHeight!;
//Zone.root.print('LayoutBuilder');
return StatefulBuilder(builder: (context, setState) {
return Stack(
children: [
Positioned(
top: 0,
child: AfterLayout(
callback: (RenderAfterLayout ral) {
final newMaxLogHeight =
constraints.maxHeight - ral.size.height;
// newMaxLogHeight:274.33333333333326, minHeight:274.3333333333333
// newMaxLogHeight may less than minHeight a bit.
if (newMaxLogHeight - minHeight! >= 0 &&
_maxHeight != newMaxLogHeight) {
setState(() => _maxHeight = newMaxLogHeight);
}
},
child: ConstrainedBox(
constraints: constraints.copyWith(
minHeight: 0,
maxHeight: constraints.maxHeight - minHeight!,
),
// 防止绘制阶段调用print显示log而触发重绘导致死循环。
child: RepaintBoundary(child: child),
),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: RepaintBoundary(
child: Builder(
builder: (context) {
return MediaQuery.removePadding(
removeTop: true,
context: context,
child: logPanelBuilder(
logNotifier,
constraints.copyWith(
minHeight: minHeight,
maxHeight: _maxHeight,
),
),
);
},
),
),
),
],
);
});
});
}