Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Flutter automatically display Cupertino UI in iOS and Material in Android with a single codebase?

Tags:

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.

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.

like image 896
SuuSoJeat Avatar asked Mar 15 '19 13:03

SuuSoJeat


People also ask

Does Flutter Cupertino work on Android?

You can technically run a Cupertino app on either Android or iOS, but (due to licensing issues) Cupertino won't have the correct fonts on Android. For this reason, use an iOS-specific device when writing a Cupertino app.

Is Flutter code same for iOS and Android?

Flutter is Google's mobile UI framework that provides a fast and expressive way for developers to build native apps on both iOS & Android, using a single codebase.

How is Flutter able to be used to create native applications for both iOS and Android devices?

Flutter uses Dart programming language and it is used to create apps for Android and iOS devices. Because it is cross-platform, a single code base can be used to create apps with a native look and feel on both Android and iOS devices.


2 Answers

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.

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.

like image 113
Gazihan Alankus Avatar answered Nov 02 '22 14:11

Gazihan Alankus


These capabilities are under development. I suggest to look into this library: https://pub.dartlang.org/packages/flutter_platform_widgets

Other than that, there is a lot you can do already, even without this library. Everything depends on your resources, requirements and complexity of your project.

For example, if you are working alone or in a small team, your project's complexity is probably not overwhelming, and your entire application will consist only of a couple of dozens of Widget derived classes at max. In this case, maybe you can deliberately program the platform-adaptive behavior in your custom Widget classes, so that you'll be happy working with them long-term.

This workflow is not always applicable, and may seem complicated at the beginning, but it will become more natural later.

like image 26
bradib0y Avatar answered Nov 02 '22 15:11

bradib0y