Advanced Flutter Project - Filtering Contributions and Building Aesthetics - Part Five

Repository

https://github.com/flutter/flutter

What Will I Learn?

  • You will learn how to add a custom Icon to a Flutter App
  • You will learn how to space out a horizontal application bar
  • You will learn about local image assets
  • You will learn how to filter through various stream events
  • You will learn how to combine streams to make new streams
  • You will learn about the PopupMenuItem and the PopupMenuButton Widgets

Requirements

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

Required Knowledge

  • A basic knowledge Programming
  • A fair understanding of Mobile development and Imperative or Object Oriented Programming
  • Basic knowledge of the BLoC

Resources for Flutter and this Project:

Sources:

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

Difficulty

  • Advanced

Description

In this video, we expand the Aesthetics of the application by adding the color theme, some images and a icon for the application launcher. We also expand the contribution BLoC so that the user can filter the contributions by category. This includes making a popup menu which the user can select the filters from and merging streams to build a new filtered results stream.

Overriding the Default Flutter Icon and Adding Local Images

There are various ways to override and implement a application launcher icon in flutter. The method of choice for this video is a library called flutter_launcher_icons. This library allows the developer to define various keys in the pubspec.yaml file or a separate .yaml file which define how the icon should look. This includes the ability to have multiple icons based on the platform and create dynamic backgrounds to fill in the gaps of the icon based on the size.


top-icon.png

In the image above, you can see the application icon for this particular application. The icon uses an image that exists on the utopian.rocks website as a sort of branding. In this image, it just floats on top of the top application bar but in the application menu, the icon is surrounded by a white square background. This same image is used on the finished application bar for when the application is actually open.

Filtering Events and Combining Streams

Other than the Aesthetic tweaks that we made in this tutorial, we implement a filter system which allows the user of the application to filter the contributions by category. This system is important because it makes it easier to parse the data in the list view and find a specific contribution. There is already a stream in the contribution bloc which creates the general list view and so it is just a matter of augmenting that stream with the user events from interacting with a popup menu. This is achieved by Combining the two streams with a function.


stream-merge.png

The original results stream is paired with the user input streamsink and then pushed through a function called applyFilter. Because the PopupMenu widget returns strings which correspond with the various contribution categories, we can easily combine the two stream's events together to create a new stream called filteredResults. This new stream returns the filtered events according to the function's logic and we are able to replace the list view's stream with this new stream. With this change, are list view can now react to the user input on the PopupMenu.

The Source Code for this video may be found here: https://github.com/tensor-programming/utopian-rocks-demo/tree/tensor-programming-part-5

Video Tutorial

Curriculum

Related Videos

Projects and Series

Stand Alone Projects:
Building a Calculator
Movie Searcher Application

Minesweeper Game

Weather Application

Redux Todo App

Curriculum

Proof of Work Done

https://github.com/tensor-programming

H2
H3
H4
3 columns
2 columns
1 column
6 Comments