Note: If you don’t have flutter installed you can use the website zapp.run
and start from step 4
lib
directory, you will find a file called main.dart
. This is the main entry point for your app.At this point run your app and you should have the default flutter template code working.
Start by deleting everything in the main.dart file and replace it with this code:
// import the material.dart from the flutter package. This holds the default styles.
import 'package:flutter/material.dart';
// This is the main entry point of the app. When it is launched this is what runs.
void main() {
runApp(const MyApp());
}
// Widget is just a class. So we are extending the capability of a StatelessWidget.
class MyApp extends StatelessWidget {
// constructor
const MyApp({super.key});
// override the base functionality
@override
Widget build(BuildContext context) {
// Material App root widget
return const MaterialApp(
title: 'Todo App',
home: Scaffold(),
);
}
}
Refresh and now you should have an empty page.
Now create a new page called Home Screen. This would be a stateful widget. Make sure to import material UI and return Scaffold();
Now let’s start designing the Home Screen. We need to store the todo items somehow. We can use a list for that. Create a list before the @override. List<String> _items = [];
Let's start styling our Home Screen. Add an AppBar on the top with the text “Tasks”. If you want you can even change the color and styles.