How to create a simple flutter app (Hello world on Flutter)
To create a simple Flutter app, you will need to have the Flutter SDK and a development environment set up on your computer. You can then create a new Flutter app using the flutter create
command in your terminal or command prompt.
Here are the steps to create a simple Flutter app:
- Install the Flutter SDK and set up a development environment by following the instructions on the Flutter website: https://flutter.dev/docs/get-started/install
- Open a terminal or command prompt and navigate to the directory where you want to create your Flutter app.
- Run the following command to create a new Flutter app:
flutter create <app_name>
4. This will create a new directory with the name of your app and generate the basic files and directories needed for a Flutter app.
5. Navigate to the new directory by running the following command:
cd <app_name>
6. To run your app in an emulator or on a physical device, use the flutter run
command. Make sure you have an emulator or device connected to your computer before running this command.
7. The flutter run
the command will build and run your app, and you should see it appear on your emulator or device.
That’s it! You have now created a simple Flutter app. You can modify the code in the main.dart
file to add your own custom logic and create your app.
Here is an example of some Flutter code that creates a simple app(Hello World)
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Flutter App',
home: Scaffold(
appBar: AppBar(
title: Text('My Flutter App'),
),
body: Center(
child: Text('Hello World'),
),
),
);
}
}