Essential Flutter Widgets When Developing Mobile App
42 Interactive
We are an AI-First automation agency focused on optimising business operations and performance.
Flutter is a popular framework for building beautiful and engaging mobile apps. Learning about the core widgets is essential if you're new to Flutter development. This article will introduce you to 2 essential Flutter widgets that you can use for every app that you create and also include the example code and demo app.
The Goals:
The Good Things:
The Challenges:
First of all, let's talk about the 2 widgets that we will discuss
Bottom Navigation Bar
The bottom navigation bar is a cool widget that has been given by the Flutter framework.
We can easily add a bottom navigation bar to the scaffold. In the scaffold, there is an attribute called bottom Navigation Bar and we can assign Bottom Navigation Bar for that. Inside the Bottom Navigation Bar class, we can define the navigation button's behavior and what the buttons need to show inside the bar.
There are mainly two attributes that are very useful when considering Bottom Navigation Bar.
Key Considerations:
type:?This attribute governs the visual behavior of the buttons when tapped. Choose between:
items:?This crucial property takes a list of BottomNavigationBarItem objects, each representing a single navigation button. You'll need at least two items to provide users with sufficient navigation options.
For Customising Navigation Items, each BottomNavigationBarItem object is comprised of two essential attributes:
Grid View
The Grid View widget serves as a versatile tool for constructing scrollable grids of child widgets. It efficiently presents your content in a well-organized and visually pleasing manner.
Key Considerations:
After we know the 2 essential widgets that are often used when building a mobile app, now our goal is to create an app using these two widgets, here I will put an example code that I have created.
Bottom Navigation Bar Widget
In the code above we create a Bottom Navigation Bar which has 3 tabs, namely Home, Favourites, and Settings.
Grid View Widget
In the code above we create a Grid View which has 2 crossAxisCounts which means the grid will have 2 columns, apart from that this grid also gets value data via dummy JSON, the function can be seen in the readJson () code section.
Home Page Screen
the code above used for display our home page screen with widget Grid View that we already created before.
Favourites Screen
that code above used to display our favourite images that we selected.
Provider
To add data to the favourite page, we create utils to handle it, the utils use the default Provider from Flutter, the implementation can be seen in the code below:
then for the final step, just call the BottomNavigationBar widget which is already filled with the Grid view widget in main. dart.
Demo
Summary
Benefits of Flutter
Learning Curve
Getting started with Flutter requires learning Dart programming language and understanding its widget system.
Essential Widgets need to be learn:
References
Are you looking for mobile app development?
We can help, let's chat.
Written by:
Fibra Diarta [Fullstack developer at 42 Interactive]
- As a part of 42 Interactive training and research programme -