your first flutter project

In this article, we’re going to create a very simple flutter project called “Hello World”. If you don’t have an environment setup, feel free to check flutter documentation first

Creating your first project

flutter create firstapp
cd firstapp

Editing /lib/main.dart

main.dart is a file which executes for the first time when you open an app. Like a C-Program, Dart also starts with main() as an initial function to execute. inside main() we need to return a runApp() with widgets This example, we have returned a simple Widget called Text()

Text Widget contains a few properties such as string, alignments, directions ..etc. (check out: https://docs.flutter.io/flutter/widgets/Text-class.html)

Final Code

import 'package:flutter/material.dart';

void main(){
  return runApp(new Text('Hello World', textDirection: TextDirection.ltr));
}

Since, main() return only one function, we can simplify this code as follow

import 'package:flutter/material.dart';

void main() => runApp(new Text('Hello World', textDirection: TextDirection.ltr));
Sundaravel M

About the author: Hey! It's me sundar. (Yea, I'm the founder of codesundar.com). I'm a passionate computer programmer who loves modern web and mobile development. feel free to reach me : Facebook - Twitter - Google+