Quick Start on main.dart
¶
Follow these steps to set up a basic Flutter app in main.dart
:
-
Open
main.dart
-
Delete all existing code
-
Import
material.dart
:dart import 'package:flutter/material.dart';
-
Define the main() method: Every Dart program begins with the main() method. Here's a basic setup:
- Start with a
MaterialApp
: Always initiate your Flutter app with aMaterialApp
. Create a class, such asMyApp
(feel free to rename it): - Create the main screen: You need to define a main screen class inside
main.dart
. Here is how to create one: - Save your changes
- Run the app: Execute your app in debug mode on Chrome.