First Flutter Application

Shahnawaz AlamShahnawaz Alam
2 min read

​In this blog post, we will be discussing how to create a flutter application and run it. A flutter application is created using the Dart programming language and the Flutter SDK. The dart:ui library provides the basis for all of the Flutter UI components. The following steps will be covered:

  1. Creating a new Flutter project

  2. Adding assets to the project

  3. Writing the Dart code

  4. Running the application on an emulator or device

Creating a new Flutter project:

To create a new flutter project, open the terminal and enter the following command:

$ flutter create myapp

$ cd myapp

$ flutter run

This will create a new flutter project with the name myapp. The project will contain all the necessary files and folders for a flutter project.

Adding assets to the project:

Assets are files that are bundled with the application. They can be images, videos, fonts, etc. To add assets to the project, create a new folder called assets in the root of the project. Then, add your assets to this folder. For example, to add an image called my_image.png, add it to the assets folder.

Writing the Dart code:

The Dart code for a flutter project is written in the main.dart file. This file contains the code for the application's UI and logic. The following code creates a simple button that says "Press me!":

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Flutter App'), ), body: Center( child: RaisedButton( child: Text('Press me!'), onPressed: () {}, ), ), ), ); }}

Running the app on an emulator/ device:

To run the application on an emulator or device, use the following command:

$ flutter run --release

This command will build and run the application on an attached device or simulator. If no devices are attached, this command will launch an emulator.

0
Subscribe to my newsletter

Read articles from Shahnawaz Alam directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shahnawaz Alam
Shahnawaz Alam

Hi, I’m Shanawaz, a web developer with 1 years of experience in full stack web developer. I specialize in ReactJS and React Native and have worked on projects such as different filed website like blog, news, e-comers, social media etc. I have a degree in Bachelor of Technology with Computer Science Engineering from MM Deemed to be University, Mullana.