Flutter is a new cross platform development framework developed by Google. With Flutter we can create Android, iOS, Linux, macOS, Windows, Google Fuchsia... In this flutter article we are going to learn how to create first flutter application with Android Studio IDE.
Step 1: Download Latest Android studio and install android studio for flutter
Step 2: Run android studio
Step 3: Now
Select File-> New Flutter Application
Select Flutter Application and press Next
Set the Flutter SDK path and Enter your Flutter Project name
Click Finish
Now your flutter first application will ready.
Flutter Application folder structure
Every flutter application will contains the below folder structure
Android -> Android application related files will be here.
ios -> ios application related files will be here.
lib -> This is our main file for flutter application.
Here we are going to write our flutter widgets.
test -> This will be the folder where we have Test cases
pubspec.yaml -> It is the configuration file where we will add all libraries, plugins , assets and other file configurations
pubspec.lock
Each flutter class will ends with dart extension.
main.dart is the entry point for the application
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); |
first line indicates, it will import the necessary files to run the flutter application.
main()-> This is the first method will executes while running the application.
above line of code represent the Lambda expression, we can write above code like below
void main(){ |
whenever their is single line of code inside {} braces we can write that like above.
compiler not through any errors.
class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: Center( child: Text("First Flutter Demo Application"), ) ); } } |
Now you can run your first flutter widget
Article Contributed By :
|
|
|
|
742 Views |