Building a Calculator Layout using Dart's Flutter Framework

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You will learn how to use flutter expanded widgets to fill out areas
  • You will learn how to make use of axis alignment in flutter
  • You will learn how to use text styling to manipulate the font properties of text widgets
  • You will learn how to make classes that generate widgets to save code

Requirements

Difficulty

  • Intermediate

Description

In this video tutorial, we build out a simple calculator layout using the flutter framework. The purpose of this exercise is to showcase the some of the layout properties in the flutter framework such as the expanded widget, the flex property, cross and main axis alignment and text styling. A calculator is a perfect choice for looking at these types of widgets because it requires the use of multiple rows of buttons and a display. Rather then using a simple grid view widget, we can easily manipulate the spacial relationship of our buttons and display by using a combination of these various different widgets.

The expanded widget is a widget that allows us to directly effect how elements fill the space of a larger widget. We can achieve this by setting up the flex of each of the expanded widgets inside of the parent container. The flex directly allows us to change how much room a child widget will take up inside of that parent widget. We can then fine tune the spacial relationships of these items using the cross and main axis alignment properties. The cross axis is the column reverse axis which runs horizontal to the main axis which is the vertical axis. Flutter's text styling allows us to change the font size, font weight, font color, and a few other properties. We can also add a third party font to the project to further customize our fonts.

We also make use of a class that can help us generate a list of widgets to fit inside of a column. In this way we can programmatically generate the buttons of the calculator by just putting in a character representation for the button. For buttons that use more then one character, we can use a ternary operator to replace the original one character representation for user clarity.

The source code for this project can be found here

Video Tutorial

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you for moderating my contribution.

Hey @tensor I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Wow so much information to digest, understand and re-read.
Thanks for sharing and educating!
If you have a minute to check out one of my posts: https://stееmit.com/@heartscally/the-chronicles-of-a-teacher-2-parent-teacher-conferences-tips-and-tricks I will be forever your fan!
Thank you!

Sorry, not really interested in the topic nor am I going to just randomly up-vote your content. If you want to build a community here on steemit, then please do so organically. Linking back to your own material in the comment section is frowned upon in most circles.

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 61491.31
ETH 3387.53
USDT 1.00
SBD 2.50