You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用在不同尺寸设备上组件大小不一致问题求助

问题:Flutter BMI计算器在不同屏幕尺寸设备上组件显示不一致

我开发的BMI计算器Flutter应用,安装在Moto One Fusion+和OnePlus 6Pro两款不同屏幕尺寸的设备上后,发现组件显示大小存在差异,预期显示效果为Moto One Fusion+设备上的样式。

以下是相关代码片段:

main.dart 代码

void main() {
  runApp(BmiApp());
}

class BmiApp extends StatelessWidget {
  const BmiApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: {
        '/input': (context) => InputPage(),
        '/calculate': (context) => CalculatedResult(),
      },
      theme: ThemeData.dark().copyWith(
        appBarTheme: AppBarTheme(
          color: Color(0xFF0A1234),
        ),
        scaffoldBackgroundColor: Color(0xFF0A1234),
      ),
      initialRoute: '/input',
    );
  }
}

input_page.dart 代码

class InputPage extends StatefulWidget {
  const InputPage({Key? key}) : super(key: key);

  @override
  State<InputPage> createState() => _InputPageState();
}

class _InputPageState extends State<InputPage> {
@override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text('BMI Calculator'),
          centerTitle: true,
        ),
        body:Column(),
      ),
    );
  }
}

所有组件均嵌套在Column中,完整代码可查看对应仓库的lib/input_page.dart文件。

内容的提问来源于stack exchange,提问作者Rahul Rasve

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 06:25:33