我想讓我的網路應用程式在螢屏變小時不會調整大小/回應。例如,當我減小瀏覽器大小時,我希望網路應用程式忽略它,而不是適應寬度和高度,而用戶只需向上、向下、向左和向右滾動即可查看網路。

uj5u.com熱心網友回復:
我建議您使用 aLayoutBuilder并最終SingleChildScrollView在大小低于您的應用程式預期時添加 a 。
這個MinSize小部件完成了它。
/// Starts scrolling [child] vertically and horizontally when the widget sizes
/// reaches below [minWidth] or [minHeight]
class MinSize extends StatelessWidget {
const MinSize({
Key? key,
this.minWidth,
this.minHeight,
required this.child,
}) : super(key: key);
final Widget child;
final double? minWidth;
final double? minHeight;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final shouldScrollVertical =
minHeight != null && constraints.maxHeight <= minHeight!;
final contentHeight =
shouldScrollVertical ? minHeight : constraints.maxHeight;
final shouldScrollHorizontal =
minWidth != null && constraints.maxWidth <= minWidth!;
final contentWidth =
shouldScrollHorizontal ? minWidth : constraints.maxWidth;
return Scrollbar(
isAlwaysShown: shouldScrollVertical,
child: SingleChildScrollView(
physics: shouldScrollVertical
? const AlwaysScrollableScrollPhysics()
: const NeverScrollableScrollPhysics(),
child: Scrollbar(
isAlwaysShown: shouldScrollHorizontal,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
physics: shouldScrollHorizontal
? const AlwaysScrollableScrollPhysics()
: const NeverScrollableScrollPhysics(),
child: UnconstrainedBox(
child: SizedBox(
height: contentHeight,
width: contentWidth,
child: child,
),
),
),
),
),
);
},
);
}
}
或者,嘗試InteractiveViewer在應用程式視窗中自由移動內容。
uj5u.com熱心網友回復:
使用SizedBox具有固定高度/寬度屬性的 a
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/410660.html
標籤:
