This video is focused on good coding practices when dealing with state management.

When you’re working with a big app that handles state management (in this case with the Provider package), then you should follow this rule:

Never allow your code to alter a list being held in the state management file, from outside.

Instead, create other methods within the ChangeNotifier file that will alter your list.

However, sometimes you need to access the list itself to retrieve some info, right?

That’s where UnmodifiableListView comes in.

It has nothing to do with the ListView widget. Instead, it’s basically an unmodifiable view OF your list.

This allows you to always access a mirror version of your list whenever you need it, while keeping your original list as a private property.

GitHub Project Repository: https://github.com/FlutterMentor/unmodifiable_listview

00:00 - Intro
00:33 - Starting Code Overview
01:52 - Showing How NOT To Do It
03:31 - notifyListeners() Method
04:52 - Making The List Private
06:35 - The UnmodifiableListView
08:39 - Like & Subscribe
08:48 - Flutter Mentor Out

#flutter #unmodifiablelistview #statemanagement

Credits:

OUTRO SONG:
Mitsubachi by Smith The Mister https://smiththemister.bandcamp.com
Smith The Mister https://bit.ly/Smith-The-Mister-YT
Free Download / Stream: http://bit.ly/mitsubachi
Music promoted by Audio Library https://youtu.be/0IgndUb1YQI

#flutter #unmodifiablelistview #statemanagement

How To Access A Private List (UnmodifiableListView Class) - Flutter Coding Best Practices
2.00 GEEK