Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

First Screen - Categories List

Premium
4 min read

Let's create our first non-authentication page, the Categories list. This will become our starting point for building CRUD operations for our application.


Create a New Screen

Let's start by creating our new screen. We will create a new file categories_list.dart in the lib/screens/categories folder.

Note: We will build the file structure in small parts. This will help us to understand the code better.

import 'package:flutter/material.dart';

Next, we need to create a new class. But this time, it is not a StatelessWidget. Instead, we will expect to have a State class.

This is required to manage the state of the screen. We will create a new class CategoriesList that extends StatefulWidget. This class will return a new class, CategoriesListState that extends State<CategoriesList>.

// ...
 
class CategoriesList extends StatefulWidget {
@override
CategoriesListState createState() => CategoriesListState();
}
class CategoriesListState extends State<CategoriesList> {
}

It looks complicated, but in short - we will initialize...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

K
kornelkornecki ✓ Link copied!

I wonder why sometimes the file names and Directories are starting with big letters (Login, Regisrer and Auth) but sometimes with small categories_list and this:

import 'package:laravel_api_flutter_app/Screens/Auth/Login.dart'; import 'package:laravel_api_flutter_app/Screens/Auth/Register.dart'; import 'package:laravel_api_flutter_app/screens/categories/categories_list.dart';

is incorrect I think. Unless there is a reason to make 2 directories screens and Screens.

I'd say we should keep the project clean and if by default the .dart files are named using all small letters (eg. main.dart) we should follow the convention. Why not to keep it that way?

M
Modestas ✓ Link copied!

First of all, the issue could be formatting - sometimes it messes the stuff up.

Now to answer the questions:

There shouldn't be a mixup like we have (it's an issue we need to fix), we should maintain a single style for all the items. Now which one is better? Not sure. We are Laravel developers and it just made sense that the package:laravel_api_flutter_app stays lowercase, but all other folders become CamelCase including the files. It might not be the best, but as long as we are consistent - that shouldn't be a problem.

But if you want to read more about it, you can find it there: https://dart.dev/effective-dart/style :)