Get Started
Welcome to a new way to build Flutter Apps with the Vyuh Framework. The concepts here are simple and you will soon be in a position to build large scale apps with minimal effort.
1. Let’s Start
Now that you have some understanding of the core concepts, let’s dig in to build our first feature with the Vyuh Framework.
Install Flutter
We assume you already have Flutter installed 😇. If not, you can always go to Flutter.dev and install it 🔗. Go through the steps outlined over there and have your Flutter setup ready.
Creating your Project
We will create the standard Flutter Application project and take off from there. On your Command Shell, run the following command in the directory where you want your project.
Next we need to add a few packages for the framework. Run this command in your project directory:
Now that you have the basics, we can start focusing on building a Feature.
2. Create a Feature
Vyuh based applications are a collection of Features. Each feature is a
descriptor which describes the feature with name
, title
, routes
, an
init
-function, etc. The mandatory ones are name
, title
and routes
. Let’s
go ahead and define a feature.
Create the feature.dart
file
Create a file, under /lib
, called feature.dart
and put the following code in
it:
Let’s take a moment to call out a few things:
FeatureDescriptor
is a way to describe a single feature. Think of it like a manifest of all things exposed by this feature. For now we will just create theroutes
.- The
routes
field is an async function that returns an array of thego_router
routes. This means, everything you know aboutgo_router
is all you need to work with routes. We don’t use any proprietary packages anywhere in the framework and leverage the best community voted packages frompub.dev
.
Create the _Counter
widget
Your dart analyzer would have already complained that you haven’t included the
implementation for the _Counter
widget. Let’s add that next.
In the same feature.dart
file, add the following code below the feature
field.
In the above code, you will notice that we are using MobX for state management. This is not mandatory, and you are free to use any state management technique you like.
Disclaimer
The creator of the Vyuh Framework has also created MobX.dart in the past. So its natural to use MobX for all state management 😇.
3. Running the app with the feature
Now we have the counter-feature ready, it’s time to invoke the runApp
method of the Vyuh Framework. Let’s go back to the main.dart
file in your
project and replace it with these lines:
Note that we are using /counter
as our initial route. This is the same route
we have exposed earlier in the feature.
Now we have the complete app ready. Let’s run it using the following command in your project directory:
After a few moments, you should see an app getting launched on your chosen device or simulator. Here’s how it looks after a couple of button presses:
Summary
If you have reached this far, we hope you were able to see a simple feature like
Counter implemented in an independent manner. With the definition of the
feature in FeatureDescriptor
, you were able to assemble a simple application.
This technique is exactly the same whether you build a single feature or
hundreds of features.
Of course, as you gain more experience, you can become more sophisticated in your approach to including features conditionally or choosing to enable features for only some of your customers. The possibilities are endless.