Flutter Material Design on iOS – system navigation over bottom button

huangapple go评论73阅读模式
英文:

Flutter Material Design on iOS - system navigation over bottom button

问题

我有一个简单的Material应用程序,其中按钮位于底部。在Android上,一切正常,但在iOS系统的底部导航栏上方会覆盖这个按钮。有什么最佳解决方案可以让按钮脱离这个导航栏并仍然在Android上正常运行?

Flutter Material Design on iOS – system navigation over bottom button

Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            flex: 2,
            child: SvgPicture.asset(
              "assets/logo.svg",
              fit: BoxFit.contain,
              width: double.infinity,
            ),
          ),
          Text(initMessage),
          const Spacer(
            flex: 1,
          ),
          ElevatedButton(
              onPressed: () => navigatorKey.currentState?.pushNamed('/help'),
              child: const Text('显示帮助'))
        ],
      ),
    );
  }
英文:

I have simple Material app where button is at bottom.
On Android it's OK on iOS system navigation bar at bottom is over this button.
What is the best solution to have button out of this navigation and still be OK on Android?

Flutter Material Design on iOS – system navigation over bottom button

Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            flex: 2,
            child: SvgPicture.asset(
              "assets/logo.svg",
              fit: BoxFit.contain,
              width: double.infinity,
            ),
          ),
          Text(initMessage),
          const Spacer(
            flex: 1,
          ),
          ElevatedButton(
              onPressed: () => navigatorKey.currentState?.pushNamed('/help'),
              child: const Text('Show Help'))
        ],
      ),
    );
  }

答案1

得分: 1

你可以将你的列部件包裹在一个SafeArea部件中,使其变为:

SafeArea {
  child: Column {

更多信息请参见https://api.flutter.dev/flutter/widgets/SafeArea-class.html

英文:

You can wrap your column widget with a SafeArea widget.

so that it becomes.

SafeArea {
child: Column { 

for more please see https://api.flutter.dev/flutter/widgets/SafeArea-class.html

huangapple
  • 本文由 发表于 2023年3月8日 16:45:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670926.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定