Build Custom FABs and Bottom App Bars inside of Dart's Flutter Framework

flutter-logo.jpg

Repository

https://github.com/flutter/flutter

What Will I Learn?

  • You will learn how to make and use custom Floating action buttons
  • You will learn how to customize the Bottom App Bar widget
  • You will learn how to manipulate Path to create custom shapes
  • You will learn about how you can create bottom drawers
  • You will learn about VoidCallback types
  • You will learn about the Rect type and how it can be used to make other shapes
  • You will learn about Inkwells

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 UI elements
  • Some understanding of overriding objects
  • 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 how we can create a custom bottom application bar widget as well as make custom Floating Action Buttons. This includes creating a floating action button that is not round as well as building a notch in the bottom application bar to better suite the new shape. In this tutorial, we also look at drawer widgets, inkwell widgets, and the VoidCallback function type.

Outline for this Tutorial
Pathing out Objects with Dart's UI library

Flutter has many of the Dart common libraries baked into it. One of the more important ones is the Dart UI library. Inside of this library, we can gain access to various different objects and functions which allow us to create different shapes. In order to create a floating action button that is not shaped like a circle, we need to use the Path object. A path is a one dimensional subset of a plane which consists of segments of various lines, arcs and beziers. These can be put together to create a shape.
path-fab.png

Above we have the path that is used to create the actual floating action button. We find an offset point where we want to start the shape at and then we create the shape by drawing from one offset to another. We are able to achieve this by using the lineTo method. This Path draws out diamond shaped floating action button. This floating action button also makes use of an Inkwell widget to give it a ripple animation effect.

Putting a Notch in the Bottom Bar

Based on the position of the floating action button in our application, we can have a notch in the bottom application bar widget. Because are new floating action button is not shaped like a circle, it makes sense to create a custom notch for it. The notch for this floating action button is computed in the floating action button class and it is then placed on top of our Bottom Bar.

diamond-fab.png

You can see the custom notch in this picture. We again use the Path object to create this notch and we draw a triangle with the path. This triangle is built by using the geometry of two separate rectangles; one from the floating action button's area and another based on the bottom app bar. We can make it look like it is cutting into the bottom bar by giving it no paint and making it into an "Open" shape.

Launching a Drawer from the Bottom

Often times it is useful to create a custom application bar to customize the layout of the application. Having customized the floating action button and notch, we also want to create a custom bottom application bar. Not only do we want this bar to be more distinct then the normal BottomAppBar widget, we also want to have the functionality to be able to launch a drawer from the bottom of the screen.

drawer.png

In this image, you can see the code that is used to actually launch this drawer from the bottom of the screen. We make use of an inbuilt function called showModalBottomSheet. This function allows us to create a builder function based on the context of the application. In the builder here, we build out a column with two listTile widgets inside of it to make it look a proper menu.

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

H2
H3
H4
3 columns
2 columns
1 column
15 Comments