【问题标题】:Container is not the same height on IOS and Android容器在 IOS 和 Android 上的高度不同
【发布时间】:2019-05-24 21:18:54
【问题描述】:

我的容器设置为高度 (110),但在 iOS (onlIphoneX) 中,它的高度类似于 90。如何解决?

在 Android 和以前版本的 Iphone 上,它是完美的。

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:pequeno_form_flutter/ui/app/login/login_block.dart';

class NavigationDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
    Color color = Theme.of(context).primaryColor;
    // TODO: implement build
    return Drawer(
      child: ListView(
        // Important: Remove any padding from the ListView.
        padding: EdgeInsets.zero,
        children: <Widget>[
          Container(
            height: 90,
            child: DrawerHeader(
              padding: EdgeInsets.all(0.0),
              decoration: BoxDecoration(
                color: color,
              ),
              child: LoginView(),
            ),
          ),

        ],
      ),
    );
  }
}

IphoneX 上的容器高度错误

在 Iphone 8 plus 及更早版本上具有正确高度的容器。

【问题讨论】:

    标签: ios android-studio dart flutter iphone-x


    【解决方案1】:

    ListView 包裹在SafeArea 中,您会看到容器恢复到原来的高度。

    SafeArea(child: ListView(...))
    

    【讨论】:

    • 完美。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2021-03-24
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 2018-12-07
    相关资源
    最近更新 更多