Reading Time: 2 minutes
Flutter is an open-source mobile app development framework developed by Google. It allows developers to create applications for iOS and Android with a single codebase.
To get started with Flutter, you first need to download and install the Flutter development kit (SDK). Then, you can create a new Flutter project using the command flutter create project_name
in the command line.
Once you have your project created, you can open it in your favorite code editor. The main file of your project is the main.dart
file, which is located in the lib
folder. This is the file that will be executed when you start your application.
The main.dart
file includes a main function called main()
, which is the entry point of your application. Inside this function, you can create your first screen (or “view”) using a Flutter widget called MaterialApp
.
import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: MyScreen(), ), ); } class MyScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('My Screen'), ), body: Center( child: Text('Hello, world!'), ), ); } }
In this example, we have created a screen that displays a navigation bar and a “Hello, world!” message. Widgets are the basic building blocks in Flutter and can be combined to create complex applications.
To run your application, connect your mobile device or start an emulator and then use the command flutter run
in the command line. Now you have your first Flutter application running on your device.