To make your first app in Flutter, follow these steps:
1. Open your preferred code editor (e.g., Android Studio, Visual Studio Code) and create a new Flutter project by selecting "New Flutter Project" from the project selection screen.
2. Choose the "Flutter Application" project type, and give your app a name.
3. Once the project is created, open the main.dart file located in the lib directory.
4. Replace the code in main.dart with the following code:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My First Flutter App',
home: Scaffold(
appBar: AppBar(
title: Text('My First Flutter App'),
),
body: Center(
child: Text('Hello World!'),
),
),
);
}
}
This code creates a simple app with an AppBar and a centered Text widget that displays "Hello World!".
5. Save your changes and run the app by clicking on the run button in your code editor.
6. You should see your app running in a simulator or on your connected device.
Congratulations! You have just created your first Flutter app. From here, you can start exploring the Flutter framework and building more complex apps.