Using the Cupertino Library to Add iOS Themed Widgets to the App in Dart's Flutter Framework — Steemit

Using the Cupertino Library to Add iOS Themed Widgets to the App in Dart's Flutter Framework

in utopian-io •  6 months ago

flutter-logo.jpg

Repository

https://github.com/flutter/flutter

What Will I Learn?

  • You will learn about the Cupertino Library in Flutter
  • You will learn how to use a Cupertino Tab Scaffold
  • You will learn about the Cupertino Tab Bar
  • You will learn about Cupertino Page Scaffolds
  • You will learn about the Cupertino themed Slider, Switch and Button
  • You will learn how to use the Media Query inherited Widget to change padding

Requirements

System Requirements:
OS Support for Flutter:
  • Windows 7 SP1 or later (64-bit)
  • macOS (64-bit)
  • Linux (64-bit)

Required Knowledge

  • A little understanding of theming
  • Some understanding of aesthetics and libraries
  • A fair understanding of Mobile development and Imperative or Object Oriented Programming

Resources for Flutter and this Project:

Sources:

Flutter Logo (Google): https://flutter.io/

Difficulty

  • Intermediate

Description

Outline and Overview

In this Flutter Video Tutorial, we take a look at some of the important Cupertino themed widgets that exist in the Flutter SDK. Cupertino is a theming convention that is associated with iOS applications and it is comparable to Google's Material Design Specification. Because Flutter targets both iOS and Android out of the box, the library includes widgets that work towards theming the application with a Cupertino theme and a Material Design theme. We check out how we can specifically use the Cupertino themed widgets to build something that looks more native to iOS.

Outline for this Tutorial
Theming with Cupertino

One of the most important widgets in the flutter framework is the Material Application Widget. Despite its name, we still need to use this widget inside of a Cupertino Themed application. This is because the Material Application widget provides a bunch of setup tools for the flutter application that would not work without it. Despite this, however, the Material Application widget does not theme the application towards the material design specification. If we want to use Cupertino based widgets we can simply import the Cupertino library.

cupertino_tab_bar.png

In this piece of code, we make use of the Cupertino Tab Scaffold widget to create a set of tabs on the bottom of the screen. The layout of this code is very similar to the Material BottomNavigationBar widget and it even uses the BottomNavigationBarItem widget to define the tabs for the navigation bar. We also have a CupertinoTabView below this which is a navigation widget that we can use to add that kind of functionality to our application.

Scrolling Cupertino Style

The Cupertino library comes with many different scaffolding widgets. The most important of these is the CupertinoPageScaffold widget. This widget allows us to define a basic Cupertino layout for a page. This includes a scrolling widget page which we can build using a set of silvers and a CustomScrollView. In this case we can also use a CupertinoSliverNavigationBar which gives us some special functionality when we scroll the screen up and down.

scrolling.gif

In this animated gif, you can see how the title starts in the left side of top bar. When we scroll the screen upwards, this title is removed from the left side and then placed into the middle of the bar that hangs over the body. When we scroll the screen back downwards this title is then placed back on the left side of the bar. This type of functionality is very common in native iOS Cupertino style applications.

Specific Cupertino Themed Widgets

Cupertino has some very specific and distinct features in it. For instance, it is not uncommon for a Cupertino button to have a white background and some colored text. The CupertinoButton widget allows us to create buttons that look like this and it also allows us to add color to the background of the button. We have access to a CupertinoSlider and a CupertinoSwitch which both feature very distinct themes and styles.

button-slider-switch.png

In this code, we have the CupertinoButton, CupertinoSlider and CupertinoSwitch. All of these widgets have a code pattern that is almost exactly the same as their material design counterparts. This is a very important aspect of Flutter because it is common for an application to have both types of widgets inside of it to accommodate both platforms. If the material design button functioned in a way that was completely different from the CupertinoButton then coding in this way would become confusing.

The source code for this project can be found here

Video Tutorial

Projects and Series

Stand Alone Projects:
Building a Calculator
Movie Searcher Application

Minesweeper Game

Weather Application

Curriculum

Proof of Work Done

https://github.com/tensor-programming

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Great work @tensor.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

·

As always, thank you for moderating my contributions.

Nice tutorial! This will be useful for cross platform developers to keep their apps consistent across all platforms.

Hey @tensor
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

I'm not sure you know how helpful this is. I'm new to Flutter and I prefer the look of Cupertino, but I couldn't find any good examples or tutorials on how to use the framework! Yours greatly helped me.

·

It does make sense that most flutter videos and tutorials would cover material since it has more widgets right now. Its likely that the team will add more Cupertino widgets to the library either before the release or after the release to make the experience similar to the material one. Anyhow, I am glad you found it useful.

Cheers mate.