search

New

6/recent/ticker-posts

Flutter First Start Application

In this section, we are going to learn how to create a flutter application in Android Studio. It is simple how to create it by following the steps below:

Step 1: Open the Android Studio.

Step 2: Create the Flutter project. To create a project, go to File New --- New Flutter Project by following screen below.

Step 3: Select New Flutter Application-> click Next, as shown in the below screen.

 

Step 4: Next, Input application details as shown in the below screen then click on the Next button.

Step 5: In the next setup domain name then click the Finish button.  

 

Step 6: Here is the structure of flutter application, let's discuss together:

  

.idea: This folder is at the very top of the project structure, which holds the configuration for Android Studio.

.android: This folder holds a complete Android project and used when you build the Flutter application for Android. When the Flutter code is compiled into the native code, it will get injected into this Android project, so that the result is a native Android application.

.ios: This folder holds a complete Mac project and used when you build the Flutter application for iOS. It is similar to the android folder that is used when developing an app for Android.

.lib: It is an essential folder, which stands for the library. It is a folder where we will do our 99 percent of project work. Inside the lib folder, we will find the Dart files which contain the code of our Flutter application.

.test: This folder contains a Dart code, which is written for the Flutter application to perform the automated test when building the app. It won't be too important for us here.

.gitignore: It is a text file containing a list of files, file extensions, and folders that tells Git which files should be ignored in a project.

.metadata: It is an auto-generated file by the flutter tools, which is used to track the properties of the Flutter project.

.packages: It is an auto-generated file by the Flutter SDK, which is used to contain a list of dependencies for your Flutter project.

flutter_demoapp.iml: It is always named according to the Flutter project's name that contains additional settings of the project. This file performs the internal tasks, which is managed by the Flutter SDK, so you do not need to edit the content manually at any time.

pubspec.yaml: It is the project's configuration file that will use a lot during working with the Flutter project. It allows you how your application works. This file contains:

  • Project general settings such as name, description, and version of the project.
  • Project dependencies.
  • Project assets (e.g., images).

pubspec.lock: It is an auto-generated file based on the .yaml file. It holds more detail setup about all dependencies.

README.md: It is an auto-generated file that holds information about the project. We can edit this file if we want to share information with the developers.

Step 7: Open the main.dart file and replace the code with the following code snippets.

import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

 

 Here is the run of testing our Flutter Application

 

Thanks

Post a Comment

0 Comments

Contact Form

Name

Email *

Message *

Random Products

Learning English