Creating a Hello World App in Android Studio with Flutter

0 views
10 months ago

Flutter is a popular open-source framework for building natively compiled applications for mobile, web, and desktop from a single codebase. In this tutorial, we'll walk you through the process of creating a simple "Hello World" app using Flutter in Android Studio.

Prerequisites

Before you begin, make sure you have the following prerequisites:

  • Android Studio installed on your computer
  • Flutter SDK installed
  • Basic knowledge of Dart programming language

Step 1: Install Flutter Plugin in Android Studio

If you haven't already, open Android Studio and install the Flutter plugin. This plugin provides the necessary tools for developing Flutter applications within Android Studio.

Step 2: Create a New Flutter Project

Now, let's create a new Flutter project. Follow these steps:

  1. Click on "File" > "New" > "New Flutter Project."
  2. Choose "Flutter Application" as the project type and click "Next."
  3. Enter your project name (e.g., HelloWorldApp), choose a location for your project, and click "Next."
  4. Configure your project details, such as the Flutter SDK path, project description, and organization, and click "Finish."

Step 3: Edit the Main Dart File

Flutter apps start with a main Dart file. Open the main.dart file located in the lib directory of your project.


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('Hello World App'),
        ),
        body: Center(
          child: Text('Hello, World!'),
        ),
      ),
    );
  }
}
    

This code defines a basic Flutter application with a simple "Hello, World!" message.

Step 4: Run Your Flutter App

Now, it's time to run your Flutter app:

  1. Connect a physical Android device or start an Android emulator.
  2. In Android Studio, click the green "Run" button or press Shift + F10.
  3. Wait for the app to build and launch on your device or emulator.

You should see your "Hello, World!" app displayed on the screen.

Congratulations!

You've successfully created a "Hello World" app using Flutter in Android Studio. This is just the beginning of your Flutter journey, and you can now start exploring the vast possibilities of building cross-platform mobile applications with Flutter.

Flutter is a powerful framework for building beautiful and performant mobile apps. In this tutorial, you learned how to set up a Flutter project in Android Studio and create a simple "Hello World" app. As you continue your Flutter development journey, you'll discover many more features and widgets that allow you to build complex and engaging applications.

Happy coding!