- Flutter Commands Cheat Sheet Printable
- Flutter Commands Cheat Sheet Answers
- Flutter Command Line
- Flutter Build Command
T o add a shel l command: T o o l s Cr e a t e cmd l i n e l a u n ch e r 2. T o open f rom t ermi nal: cd flutter app main folder idea. Flutter IntelliJ cheat sheet (MacOS version) Core workf l ow Run: ctrl-r S t art w/ o breakpoi nt s. Debug: ctrl-d S t art w/ B reakpoi nt s. The following PHP cheat sheet can help you review basic commands, such as before you take a PHP exam. However, since it’s a language, this guide is simply a list of the commands, and more commands can be further explained through other cheat sheets found online.
In this tutorial you will learn how to create a MobX version of the default Flutter 'counter' app.
- Flutter has a few builtin tools for helping you debug layouts. Flutter Inspector. In Android Studio you can find the Flutter Inspector tab on the far right. Here we see our layout as a widget tree. Visual rendering. You can turn on visual rendering by setting debugPaintSizeEnabled to true in your main function. In your main.dart file replace.
- A quick cheatsheet of useful snippet for Flutter. A widget is the basic type of controller in Flutter Material. There are two type of basic Widget we can extend our classes: StatefulWidget or StatelessWidget. StatefulWidget are all the widget that interally have a dynamic value that can change during usage.
- Note that the basename of the part-file must match the containing-file exactly! In the above case, the part file is called todo.g.dart, which matches the todo.dart file in which it is contained. To generate the part-file, you have to run the following command: flutter packages pub run buildrunner watch -delete-conflicting-outputs.
Prepare
- Before starting this tutorial make sure you have flutter installed and know how to create a new flutter project.
- Create a new flutter project on your computer to start.
Install Dependencies
Add the following dependencies to your pubspec.yaml
file.
Next add the following dev_dependencies:
In your project folder, run this command to fetch all the packages:
At this point you should have all the necessary packages to continue development.
Add a Store
Now, let's create a MobX store. A store in MobX is a way of collecting the related observable state under one class. The store allows us to use annotations and keeps the code simple. Create a new file counter.dart
in lib
folder and add the following code to it.
The interesting parts here are:
- The abstract class
_Counter
that includes theStore
mixin. All of your store-related code should be placed inside this abstract class. We create aCounter
class to blend in the code from thebuild_runner
. - The generated code will be inside the part file:
counter.g.dart
, which we include with thepart
directive. Without this, thebuild_runner
will not produce any output. The generated file contains the_$Counter
mixin.
Note
It is essential to use proper casing for the file name, else the build_runner
will not generate any output.Since our file is called counter.dart
, the part file must be named as counter.g.dart
(note the lowercase letters)
- The
@observable
annotation to mark thevalue
as observable. - Use of
@action
to mark theincrement()
method as an action.
Run the following command inside your project folder. This generates the code in counter.g.dart
, which we have already included as part file.
On the command-line, here's the output we got from running it. Yours might be slightly different.
Stay on watch

If you are making changes to the store and want to generate *.g.dart
files automatically, you can use the following command:


Starting Clean
Sometimes you may have an error running this command due to existing files, possibly generated from an earlier version ofbuild_runner
. In that case, you can add the following flag to delete the *.g.dart
files before generating them.
Connect the Store and add an Observer to your Widget
Now comes the part where we connect the MobX store to the Widget. In your main.dart
file, replace the code with the following:
Flutter Commands Cheat Sheet Printable

You will notice above that we have not used any StatefulWidget
instances! The state is stored in the Counter
store and the Observer
widget reads the counter.value
to render the count. Just the simple act of reading the counter.value
is enough for the Observer
to start tracking and re-render on changes.
And we are done!
Flutter Commands Cheat Sheet Answers
Our end result will look exactly the same as our start! As you tap on the FloatingActionButton
, the counter will increment and update automatically.
Flutter Command Line
Keep exploring!
Flutter Build Command
Browse through other examples to get a feel for MobX. It's all about Observables
, Actions
and Reactions
😇. We have already looked at Observables
and Actions
. Reactions
are covered in other examples.
