Flutter is a popular open-source UI software development kit created by Google. It is used to develop natively compiled applications for mobile, web, and desktop from a single codebase. This tutorial will guide you through the basics of Flutter mobile development.
Prerequisites
Before you start, make sure you have the following prerequisites:
Getting Started
To create a new Flutter project, use the following command:
flutter create my_flutter_app
This will create a new directory with all the necessary files to start your Flutter app.
Building Your First Flutter App
Step 1: Open Your Project
Open the project directory in your preferred code editor.
Step 2: Update main.dart
Open the lib/main.dart
file and replace its content with the following:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Demo Home Page'),
),
body: Center(
child: Text('Hello, World!'),
),
);
}
}
Step 3: Run Your App
To run your app, use the following command:
flutter run
This will launch your Flutter app on the connected device or emulator.
Further Reading
For more information on Flutter mobile development, check out the following resources:
