Cupertino in practice

Our Favors app is designed to use Material Design components, but we can choose to make it look more native in iOS by using Cupertino widgets. This can be done with a combination of conditions during the build of our widgets using the Platform class.

We can, for example, design a Cupertino alternative for the first favors screen:

As you can see, in the iOS Cupertino variant, we have the navigation bar at the bottom of the screen instead. OK, this does not look very good, but the important thing is the idea of making custom layouts based on the target platform. Flutter gives you the tools; you must use them properly.

You can find the source code of hands_on_cupertino_theme example on GitHub to see all the conditions and changes made to use Cupertino widgets. The theme part is omitted as it works in very similar way to Material Design.

We need to make a check on target platform and build different widgets depending on it. This can be quite complicated, so an alternative is to develop separated widget classes for each platform and to not mix up all the code, which helps with organization.

In our example, we have only made the first screen in order to illustrate how the tree can be conditioned based on the platform. The Favors app will have the same style on both platforms. Now, let's see how to use custom fonts to give a brand focus on applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.107.96