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

Pubblicato il: 10 giugno 2021
sul canale di: Flutter Mentor
692
36

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/unmo...

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    • Mitsubachi – Smith The Mister (No Cop...  


In questa pagina del sito puoi guardare il video online Flutter Coding Best Practices - How To Access A Private List (UnmodifiableListView Class) della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Flutter Mentor 10 giugno 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 692 volte e gli è piaciuto 36 spettatori. Buona visione!