本文介绍了Flutter是否可以通过单个代码库自动显示iOS中的Cupertino UI和Android中的Material?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道Flutter是否会使用单个代码库在iOS上渲染iOS Cupertino风格,在Android上渲染Material.在开始使用Flutter开发我的应用程序之前,我想知道这一点.

I need to know whether Flutter will render the iOS Cupertino style on iOS and Material on Android with a single codebase. I want to know this before starting to develop my app with Flutter.

如果不是,我将如何在一个代码中管理两个不同的UI?我不可能在代码的任何地方都使用if/else.

If it's not, how would I manage the two different UI in a single code? I can't possibly use if/else everywhere over the code.

推荐答案

您应尝试使用图库应用程序: https://play.google.com/store/apps/details?id=io.flutter.demo.gallery&hl=zh_CN ,当您按下菜单按钮时,您可以将平台机制设置为Mountain View(Android)或Cupertino(iOS).这样一来,您可以看到在任何一个平台上它的外观.

You should try the gallery app: https://play.google.com/store/apps/details?id=io.flutter.demo.gallery&hl=en In there, when you press the menu button you can set platform mechanics to be Mountain View (Android) or Cupertino (iOS). That way you can see how it's going to look in either platform.

以下是根据平台选择具有代码的Cupertino或Material的示例: https://medium.com/flutter-io/do-flutter-apps-dream-of-platform-aware-widgets-7d7ed7b4624d 据我所知选择这样的小部件.

Here is an example of selecting Cupertino or Material with code depending on the platform: https://medium.com/flutter-io/do-flutter-apps-dream-of-platform-aware-widgets-7d7ed7b4624d As far as I know you have to choose the widgets like this.

这篇关于Flutter是否可以通过单个代码库自动显示iOS中的Cupertino UI和Android中的Material?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:05