Hello world in flutter
Flutter is cross-platform. When you create a new project using a flutter, at that time you will see some folder in which you will work and here some are works as a passive folder. Passive folder means it is there in your project but not be used or we can say edited by us. It is very important to have an idea of each and every folder and project structure. Let’s dive into it.
A lot to know a lot to discuss.
.dart_tool folder: – It contains the package_config.json file.
Idea folder: – It contain the configuration information for Android Studio. So, if you are using VS Code then no need to worried about it.
Android Folder: – This is not the place where we write our project code, as we know using flutter, we can create IOS And Android based app. So, for programming point of you it is not important but at the run time it play very important role. Let’s take a look how. When you run your project code it will turn into Native code right? I hope you have already read my previous post. Here your native code will get injected into this Android folder. That will use into a real android app.
Same way IOS Folder work. But you if your using WINDOWS. Then you won’t be able to work with.
Lib: – Main folder (AS PROGRAMMER POINT OF YOU ACTIVE FOLDER) for the development perspective. All the code which we want to implement in our application will be place here using the file with the extension “xysFilename.dart”.All the file placed inside this folder publicly avaliable to other packages.
Test folder: – As the name implies contains test related to code here. Nothing rocket science in it.
.Gitignote: – It is related git, and here we are interested to learn flutter. So some other time I will explain starting from scract how you can use git and share your code, do the hosting and other stuff.
.Metadata File: – managed by flutter.
.package file: – generated by SDK.
My_code_flutter.iml: – Automatically managed by Flutter SDK. This is a typical IntelliJ project file, which contains the JAVA_MODULE information used by the IDE.
Pubspec.lock: – managed by flutter.
Pubspec.yaml: – Now here comes the main advantage of cross-platform.Have you heard about MVC CORE? When we work with MVC Core using Microsoft Visual studio version at that time you may use the Nuget. The packet manager, which will helps us to take as many items as your project needs. Same way here we will place our third party tool related code inshort all the dependency will be placed. Let’s understand Pubspec.yaml: in detail.
- name:- It is necessary. You can use lowercase,digit and ” _ “. And should be valid identifier.
- description:- It is optional. You can specify the reason of this package.
- version:- Defines version and build number. Both the version and the builder number may be overridden in flutter
- dependencies and dev_dependencies:- A listing of third-party packages is required for the usage of the library and the development of the library.
- environment:- Here you need to specify the target and the supported Dart SDK versions.
.packages:- Mapping operation perform here like, it simply stores the mapping between the packages and its location in the system. So, in future it will available for you to import inside your Project code.
pubspec.lock:- When you open this file you will see “It is generated by pub”.It also contains the exact versions and other metadata information about all of the dependencies. So, it is better not to touch this files.
Imp point:- Flutter follows the hot to reload command means your command prompt have a code like “Flutter run”. And if you make any changes in your code and save. Automatically your output devices get affected.In flutter everything is WIDGET. So, let’s check out some code.
In above image you can see the “statelesswidget”, meaning I will cover in next blog post.Let’s discuss other point,in image below,
Line 10:- I am using MaterialApp widget, which again uses home, and inside the home, it uses a Text widget. When you save and check your device if everything is fine then you will see the hello world message.
The Build method will be called by itself whenever it is required.