Flutter Beginner Handbook (1)
Flutter Beginner Handbook (1)
1
Programming Fundamentals
2
Everything is a Widget
3
Navigation
4
User Interaction
5
Backend
6
Frontend
0
introduction
Why did i write this book?
This is a book I wish I had when I first started learning Flutter. I
will condense everything that I believe is essential into this guide
so that you can go off and create amazing apps yourself. My
learning philosophy is to make everything simple. Coding
software applications can get very complex and there are many
branches of development that can seem almost endless,
especially if you’re just starting out. My goal with this book is to
give a beginner enough of a foundation for you to build on from
this little toolbox.
what is flutter?
You want to make mobile apps, but you are faced with a decision:
Should I learn iOS or Android development? Do I have to commit
to one or the other? This is the major decision I had to make when
I was starting out. I had initially started making Android apps,
but very quickly I didn’t like the fact that I was limited to just one
platform. I wanted to make mobile apps that everyone can use.
How does everyone else handle this problem? It seemed like at
the time, you had to choose one platform as your main. This is
probably why most of the apps you use today are made by big
companies who have the funds to hire an entire iOS team, an
entire Android team and manage the two teams to attempt to
create a seamless experience for the end user. That’s a lot of
work, money, and people!
I designed this book for complete beginners in mind, but the only
pre-requisite is for you to have installed Flutter on your computer
and are able to run the default app when you open a new project.
If you have done that, then let's start from the very beginning!
1
programming basics
basics
variables
operators
control flow
functions
data structures
list
set
map
variables
You can store different types of information into variables. There
are several variable types you should know about.
string
A string of characters, ie. text
int
Integers / numbers without a decimal point
double
Numbers with a decimal point
bool
Boolean value / either true or false
operators
Now that you can store information into variables, you can
change, compare, and perform logic on them.
basic math operators
COMPARISON OPERATORS
LOGICAL OPERATORS
control flow
It's time to give instructions to the computer about how you want
things to be done.
if
if else
else if
If you find yourself using too many if statements, you may want
to consider using a switch statement
switch case
Imagine you have a box of ten different colored crayons and you
want to draw a small circle with each one. Instead of saying,
"Draw a circle with the first crayon, then draw a circle with the
second crayon, then draw a circle with the third crayon, etc..."
It will execute the code in the body like usual but now it returns
something, in this case, an integer.
call the function
Since our 'add' function returns an integer, we need to store that
value somehow. Let's store it in a new integer variable called
'result'.
data structures
There are different ways to store data. Here are the essential
ones.
list
These are ordered groups of items. In Dart, lists are analogous to
arrays in other languages.
set
These are unordered groups of unique items. Sets are useful when
you want to ensure that an item only appears once.
map
These store data in key-value pairs.
2
everything is a widget
In Flutter, a widget is a fundamental building block of the app.
The text looks so small though, you can barely read it!
text
You can change the text's size, weight, color and more
icon
Flutter has a big library of icons by default
app bar
The 3 essentials here are the title, color, and leading icon
column / row
You can group widgets together vertically / horizontally
You can align the children in different ways
You can align the main axis to the center
Or.. you can align the main axis to the end
Lets say one of the children is bigger
This is where the cross axis comes into play
You can align the children on the cross axis
expanded
The expanded widget goes very well with columns / rows because
it will automatically expand the widget to fill the remaining
space
One problem with columns / rows.. Sometimes, not all of it's
children fit on the screen!
For this, we need another widget
listview
Listviews are like columns / rows that can scroll
All of the children now fit because this list is scrollable
listview.builder
You can generate lists on demand like this
gridview.builder
You can create grids on demand like this
stack
A stack, like the name suggests, stacks widgets on top of each
other
Like columns / rows, stacks also have alignment properties
gesture detector
This widget allows it's child to be tappable by the user. Here are a
few of the main gestures
3
navigation
routes
In your material app, you can define the routes to the different
screens
1st screen
This is our first screen, it has a button in the center that when
pressed, sends us to the second screen
2nd screen
This is our second screen. We just used 'push' to go to a new
screen, now you can use 'pop' to go back.
drawer
A drawer widget is a common way to organise a list of pages a
user can navigate to
You can open the drawer by tapping on the menu icon
When the user taps on the bottom nav bar, we want to navigate
to the correct page.
Lets keep track of which page to display using the integer
_selectedIndex
To Do app
Notes app
Login app
6
frontend / design
"Design is not how something looks, it's how something works."
- Steve Jobs -
simple is beautiful
An amateur mistake is to want to jam pack as many features as
possible into the app since more = better .. right?
NO! It shows a lack of focus and clarity about what the identity of
the app is. The user should know immediately what the app is
about without needing a manual or an explanation on how to use
it. This means the design needs to be intuitive.
Think about this..
How can you remove as much as possible while still leaving the
core identity?
Before you try to make your app look pretty on the eye, you first
need to do some soul searching about what the app is for.
What is the ONE THING the user should do one your app?
Instead of using multiple colors pick one main color and use
different shades of that color. It will create an overall vibe and
feeling.
what are you going to
build?