Hello World App

On Last Post, You learned how to Setup Flutter, Now We will learn how to create Project in Flutter and Run in Emulator

If you are working with VS Code, You need to press Ctrl + Shift + P or Cmd + Shift + P (in Mac) then Select Create New Project, Then Select Folder location where you want to save Your Program.

You will get a Demo Counter Application Source code, You can run that directly in Emulator but for now just remove that code and write this one :

import 'package:flutter/material.dart';
void main() {
  runApp(new HelloWorld());
}
class HelloWorld extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'First App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Home Page'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

  • First we import package
  • as C Language Flutter start run from main() method
  • Every Flutter class extends StatelessWidget or StatefulWidget
  • this class has build method
  • One App has only one MaterialApp which has title, home
  • home return Scaffold Class which has appbar, body attributes
  • AppBar is the ActionBar of application
  • body returns Widget to display Widget in screen

To get details about Flutter Widget. Go to Widget Introduction

Hello World App
Share

You may also like...

1 Response

  1. Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Leave a Reply

Your email address will not be published. Required fields are marked *