Skip to main content

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

Read more here

Partial Widgets - Code Refactoring

Premium
8 min read

If we look at our categories_list.dart file - it is getting a bit long. So let's make this lesson about refactoring some code into separate files. Here's what we will do:

  • Move our Model into its own file
  • Move all of our API calls into a service file
  • Move the Category Edit button into its own file (along with all the logic)

These actions will set us up for a more modular and maintainable codebase.


Moving Category Model

Let's start by moving our simplest code - the Category model. Create a new...

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

JV
Jose Valle ✓ Link copied!

Hi, I stopped following tutorial at this point. I've been copy & pasting and fixing minor issues all the way, but at this point are more issues I can't fix.

The login part ever worked. I had to register each time to get the category listing, but it doesn't works fine, because users are not registered and all categories are listed anyway.

I tried copying whole code from repository but didn't get working neither.

I would suggest to include some instructions to get the flutter code on the repository working.

M
Modestas ✓ Link copied!

Hi, it is possible that versions have changed and there are differences.

In any case, there is no special instructions to really launch it... At least at the time of writing there was none.

May I ask about your dev env? What are you using? And what are the issues you encounter?

I will revisit this tutorial, but I am not sure what might be broken when following. It is possible we missed some information, but I do need some examples.

Thanks!