Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Build a Flutter Stopwatch App with Custom UI and Animations
Rating: 4.7 out of 5(60 ratings)
421 students

Build a Flutter Stopwatch App with Custom UI and Animations

Learn how to use Flutter tickers, matrix transforms, and other custom widgets to build a clone of the iOS Stopwatch app
Created byAndrea Bizzotto
Last updated 12/2021
English

What you'll learn

  • Learn about how to create performant Flutter UIs that update every frame at 60 fps
  • Work with custom Flutter layout widgets: Stack, Align, Positioned, AspectRatio, LayoutBuilder, Transform
  • Work with matrix transforms (scale, rotate, translate) to create custom Flutter UIs
  • Build a clone of the iOS stopwatch app

Course content

1 section16 lectures1h 9m total length
  • Course Introduction1:34

    In this section will complete a UI challenge and build a stopwatch application.

    The two most important topics we will cover are tickers and matrix transforms.

    - Tickers are at the foundation of the Flutter animation framework. By learning what they are and how to use them you'll get a much better understanding about how animations work under the hood.

    - When you build custom UIs with animations, you'll often need to translate, rotate or scale widgets on screen. Matrix transforms are key in understanding how to do this.

    We'll also get some practice working with widgets such as Stack, Align, Positioned, AspectRatio, LayoutBuilder, and cover a bit of state management.

  • Starter project for the Stopwatch app2:35

    Download the stopwatch_flutter.zip starter project, set up with Flutter and Dart SDK 2.12, and explore the custom stopwatch UI, animated elapsed time, and duration formatting.

  • Dark Mode and Custom System UI Overlay1:47

    Enable dark mode by applying ThemeData.dark to the MaterialApp and setting scaffoldBackgroundColor to Colors.black. Wrap the scaffold with AnnotatedRegion<SystemUiOverlayStyle> and apply SystemUiOverlayStyle.light to customize the status bar.

  • Creating a periodic Timer4:59

    Set up a periodic timer to update the stopwatch by capturing the start time with DateTime.now and computing elapsed time, then render with a fixed-width ElapsedTimeText for readability.

  • Ticker and TickerProvider5:44

    Replace timer with a ticker that syncs to the screen, delivering 60 frames per second updates for a Flutter stopwatch and exposing elapsed time via callbacks.

  • Creating a separate StopwatchRenderer widget2:30

    Use matrix transforms to render the stopwatch UI with tick markers, five-second labels, and a clockwise clock hand, and move UI into a StopwatchRenderer widget that takes elapsed time.

  • Sizing the Stopwatch UI with AspectRatio2:34

    Learn matrix transforms by using a stack to render ElapsedTimeText, wrap in an AspectRatio of 1.0, and add a padded container to create a centered square stopwatch UI.

  • Matrix transforms7:26

    Explore matrix transforms in Flutter by using the Transform widget and Matrix4 to translate, rotate, and scale widgets, control origin with alignment, and chain multiple transforms for 3D space effects.

  • Getting the circle radius from LayoutBuilder3:34

    Derive the circle radius from layout constraints with LayoutBuilder and pass it to StopwatchRenderer to render a responsive stopwatch circle, using a decorated container for visualization.

  • Implementing the animated clock-hand6:52

    Design a reusable ClockHand widget that animates a clock hand clockwise using elapsed time and matrix transforms, then position and rotate it in a stack to complete a minute rotation.

  • Completing the stopwatch UI (part 1)6:15

    Extend the stopwatch user interface by rendering 60 tick markers around a circle with a clockSecondsTickMarker widget, using matrix transforms, rotation, and color logic for multiples of five.

  • Completing the stopwatch UI (part 2)7:40

    Complete the stopwatch user interface by adding five-second markers with a reusable ClockTextMarker widget, using matrix transforms, sized boxes, and a loop to position 60-second markings.

  • Adding the start/stop/reset functionality (part 1)5:03

    Add start, stop, and reset functionality to the stopwatch with custom buttons built from InkWell, Material, and clip oval. Use stack and align to position them and adjust aspect ratio.

  • Adding the start/stop/reset functionality (part 2)5:15

    Implement start, stop, and reset logic for a Flutter stopwatch by managing an is running flag, ticker control, and elapsed time with previously elapsed and currently elapsed getters.

  • Performance considerations and completed project4:56

    Refactor the stopwatch UI to redraw only the parts that change at 60 fps. Implement a ticker UI widget and a global key to refresh only moving parts.

  • BONUS Lesson & Next Steps0:48

    Explore further with a complete Flutter animations course, featuring seven hours of content to build a fully custom habit tracking app with advanced features and challenges.

Requirements

  • You should already be familiar with the Dart language and how to build simple Flutter apps
  • You should already have the Flutter SDK installed (2.0 or above) and an IDE configured for Flutter development
  • You can use the Android Emulator (on Windows) or iOS Simulator (on macOS) for development

Description

Want to learn how to build completely custom and performant UIs in Flutter?

This practical course will teach you exactly that, by showing you how to create a clone of the iOS stopwatch app from scratch.

As part of this, you'll learn about the foundations of the Flutter animation framework and build a completely custom UI using:

  • Ticker and TickerProvider

  • Matrix Transforms

  • Stack, LayoutBuilder, AspectRatio, and other layout widgets

Would you like to:

  • build UIs that render every frame, in sync with the screen refresh rate, and without compromising performance?

  • rotate, scale, or translate widgets, and combine them all together to build custom UIs?

Then you've come to the right place.

This course is short and to the point. But it will give you valuable knowledge and a few tricks that will come handy in your future Flutter projects.

What does the completed project look like?

Go check the video preview for a complete overview of the project you'll build in this course.

Other things included in the course:

- How to switch betwen light and dark mode

- How to manage the stopwatch state and start, stop, and reset the timer

- How to optimize the application performance

- How to build modular code by creating small, reusable widgets

- A final challenge to test your knowledge


Frequently Asked Questions

Will we use Flutter 2?
Yes! The entire course uses Flutter 2 with Null Safety and I will keep it up to date.

What are the course prerequisites?
You should be already familiar with StatelessWidgets and StatefulWidgets, common layouts (Row, Column, Stack), and the foundations of state management in Flutter.

Who this course is for:

  • Flutter developers looking to build custom layouts and time-based animations