Building a Countdown Timer with a Custom Painter and Animations in Dart's Flutter Framework

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You will learn how to build a custom painter and canvas to build out shapes and animations
  • You will learn how to use aligns, aspect ratios and position fill widgets
  • You will learn how to use complex custom theme data sets

Requirements

Difficulty

  • Intermediate

Description

In this Flutter video tutorial, we build out a countdown timer application. This application makes use of a custom painter and canvas to generate two circle shapes. The first circle shape acts as a background circle and the second one slowly fills out the background circle giving the user some idea of how much time has passed.

We are able to style the application by using a theme widget inside of the main root widget. This theme data widget lets us setup the canvas color, icon theme, accent color and the brightness of the colors. We are then able to access these values through the build context in any of our widgets. We also are able to access some of the default values that come in the basic flutter theme; including the subhead and display4 text sizes.

Inside of the circles in our animation, we place three zeroes, one for the minutes and two for the passing seconds. These numbers change in real-time based on the amount of time that is set for the duration of our animation. This means that if the animation runs for 240 seconds, then the countdown will count from 4 minutes to 0 seconds.

Our layout makes use of some new widgets; the positioned fill widget, the align widget, and the aspect ratio widget. Each of these widgets focus on one specific property. The position fill widget lets us will up a stack by default by setting the position properties to 0.0 by default. The align widget is a container with a focus on the alignment property and the aspect ratio widget is a container with a focus on the aspect ratio property.

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]

Thanks for moderating my contribution.

Hey @redart, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

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

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.034
BTC 66408.70
ETH 3225.39
USDT 1.00
SBD 4.17