如何在Flutter Web中调整浏览器页面时停止调整小部件的大小



如何停止Flutter Web中小部件的自动调整大小/响应。

有没有一种方法可以使用包裹在Scaffold上的Widget,例如,当页面窗口被调整大小时,它可以阻止Widget的调整大小?

我有一个独特的用例,其中不需要响应性(尽管我知道响应性设计通常是最好的(。

您可以修复像这样的特定小部件的heightwidth

SizedBox(
height: 300,
width: 300,
child: your_widget,
);

并用SingleChildScrollView包装父窗口小部件

您可以使用kIsWeb,这将识别您是在移动应用程序还是在web应用程序上运行。在移动设备和网络上,响应布局的输出仍然相同,但在运行网络或移动设备时会有所不同。

import 'package:flutter/foundation.dart';
kIsWeb ? WebWidget : MobileWidget

我知道有点晚了,但这对我来说是有效的:

return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 1000, //fixed width that you need
child: <your widget that you don't want to resize>,
),
]
),
)

相关内容

最新更新