Save Data to Shared Preferences in Flutter | Day 08 -

  Рет қаралды 21,267

Kilo Loco

Kilo Loco

Күн бұрын

Kilo Loco shows you how build settings page and save all the selected values to Shared Preferences. In this tutorial, you will learn about the different types of List Tiles, converting enums to and from savable states, and retrieving stored data from shared preferences.
** Show Notes and Links **
Project Files:
github.com/Kil...
Kilo Loco on Social Media:
www.kiloloco.com
Discord - / discord
Twitter - / kilo_loco
Instagram - / kilo_loco
#flutter #dartlang #30DaysOfFlutter

Пікірлер: 42
@aldrinalainroncocarrillo8076
@aldrinalainroncocarrillo8076 2 жыл бұрын
Hello kilo loco, greetings from Colombia, I just want to leave you my most sincere thanks and respect for making such high quality content, especially I take great advantage of your flutter publications, since it is what I am currently applying, thank you very much friend and God bless
@kanyevest
@kanyevest 3 жыл бұрын
it's interesting going through these and implementing null safety along the way too
@adamhowley8037
@adamhowley8037 2 жыл бұрын
Just stumbled upon your channel. Love the length of these videos. Great explanations. Thanks!
@RandalLSchwartz
@RandalLSchwartz 3 жыл бұрын
You can store the enums as String or ListString as the toString of the values, and restore them using this mapping, as demonstrated here in a dartpad snippet: void main() { var inStorage = Language.Flutter.toString(); var string2Language = Language.values.asMap().map((k,v) => MapEntry("$v",v)); var inProg = string2Language[inStorage]; print(inProg == Language.Flutter); } enum Language { Flutter, Dart, JavaScript, Perl }
@Marvelus2009
@Marvelus2009 3 жыл бұрын
this series helped me a lot with writing one of my SwiftUI apps in flutter for android, I learned so much, and it is only day 8, I'm actually excited now, thank you sir.
@bradykaiser3540
@bradykaiser3540 3 жыл бұрын
i guess Im kinda randomly asking but do anyone know a good website to stream new tv shows online ?
@guillermotrace4391
@guillermotrace4391 3 жыл бұрын
@Brady Kaiser Meh try Flixportal. just google after it:P -guillermo
@bradykaiser3540
@bradykaiser3540 3 жыл бұрын
@Guillermo Trace Thanks, I went there and it seems like they got a lot of movies there :D I really appreciate it!!
@guillermotrace4391
@guillermotrace4391 3 жыл бұрын
@Brady Kaiser Happy to help :D
@Praveenmgupta
@Praveenmgupta 3 жыл бұрын
Thanks a lot for the tutorials, I'm enjoying and learning a lot. Can you please make a video on backing up & restoring data stored in sqflite and also exporting and importing of data through csv files.
@RandalLSchwartz
@RandalLSchwartz 3 жыл бұрын
Best to have those key strings as const String then. :)
@RandalLSchwartz
@RandalLSchwartz 3 жыл бұрын
And I want to re-emphasize... your videos are great! Thank you for doing them!
@Kilo_Loco
@Kilo_Loco 3 жыл бұрын
Glad you like them!
@AbdullahHattab
@AbdullahHattab 2 жыл бұрын
Thanks for this lesson, I was wondering if I change the values too many times do they keep the old records or do they overwrite them? And if it is kept and repeated, how can I delete the old values, or in other words, how can I replace the value according to the key? Thanks again.
@RandalLSchwartz
@RandalLSchwartz 3 жыл бұрын
And thank you for TextButton!
@hoekbrwr
@hoekbrwr 3 жыл бұрын
I have a problem with null safety! You tell at 27:20 that programmingLanguages may be null, but do not handle null safety. You just go on and leave the subject unhandled. When I start my app it gives me a null object at the .map Like this: Exception has occurred. NoSuchMethodError (NoSuchMethodError: The method 'map' was called on null. Receiver: null Tried calling: map(Closure: (String) => ProgrammingLanguage)) At least it must start with an empty List of Strings. Can I create a dummy var with empty List of Strings? Obvious not I get runtime error when doing this const emptyLanguage = []; final programmingLanguagesIndicies = preferences.getStringList('programmingLanguages') ?? emptyLanguage; I am stuck! Anyone who can explain to overcome this and come from the ground up?
@Kilo_Loco
@Kilo_Loco 3 жыл бұрын
This video series doesn't cover null safety as it was not on stable at the time and is still currently an opt in feature. You may be able to solve the problem by using the ? in a few places to accommodate for null safety, but I haven't used it yet personally in dart. If I had to guess, the code should look something like this: final programmingLanguages = programmingLanguagesIndicies? .map((stringIndex) => ProgrammingLanguage.values[int.parse(stringIndex)]) .toSet() ?? Set() The idea here being that the programmingLanguagesIndicies is nullable and if the value is null, then return an empty Set
@chakroid13
@chakroid13 3 жыл бұрын
@@Kilo_Loco No its not working ..
@Build_the_Future
@Build_the_Future 3 жыл бұрын
if you are talking about the null safety in the settings, then try using the "??" like this. isEmployed: isEmployed ?? true); username: username ?? "it's null",
@tuann2507
@tuann2507 3 жыл бұрын
Try to click the continue debug button while debugging, then select the checkbox option in your simulator, then save. That's what I fix. Hopefully, it can help. I think the first run there is no saved data yet, so it catches the empty set and popup the warning. Follow my step, hope next time can run normally. If any better ways to fix it, please let me know. Cheers
@mashilheiba1nm720
@mashilheiba1nm720 2 жыл бұрын
Did you found the solution? i'm also stuck in here
@braindroid9657
@braindroid9657 2 жыл бұрын
idk why m getting an error at newValue... it doesn't show anything except red line ... any idea ??
@raomuhammadusama9244
@raomuhammadusama9244 2 жыл бұрын
It's an object error. Just change it from newValue to newValue as Gender.
@jamilurrehmanamini4878
@jamilurrehmanamini4878 3 жыл бұрын
best video please continue with flutter videos Thanks in advance subscribed
@furkanfrk5179
@furkanfrk5179 2 жыл бұрын
Thank you very clear !
@antoniodb9988
@antoniodb9988 Жыл бұрын
Bravo!👌
@masihreyhani3910
@masihreyhani3910 3 жыл бұрын
Amazing stuff! Thank you so much.
@Kilo_Loco
@Kilo_Loco 3 жыл бұрын
Glad you liked it!
@ashwantariq
@ashwantariq 3 жыл бұрын
great video man thank you
@luckimeluckimeapp5709
@luckimeluckimeapp5709 3 жыл бұрын
Thanks a lot for the tutorial, Can you please refactor the code to use a state management library like Riverpod or Bloc instead of using SetState? thanks
@Kilo_Loco
@Kilo_Loco 3 жыл бұрын
I'll be covering state management in the coming weeks 😉
@wareeffallatah1335
@wareeffallatah1335 Жыл бұрын
I am new to flutter, what is “dirty” in his code
@mazharimam9216
@mazharimam9216 2 жыл бұрын
y we didn't had any parameter in onchanged in checkboxlist
@Andy_Druws
@Andy_Druws 3 жыл бұрын
Thanks so cool video ) Ez like ^) Uh Models Uh.
@sangputuokasusila9506
@sangputuokasusila9506 3 жыл бұрын
bro, how do you get into the database?
@thrillclip
@thrillclip 2 жыл бұрын
kudos!!
@Kuuuhrizz
@Kuuuhrizz 3 жыл бұрын
I had a problem importing shared_preferences. When I added the import 'package:shared_preferences/shared_preferences.dart'; into my code, the app crashes and 60% of dart started eating my cpu.
@Kuuuhrizz
@Kuuuhrizz 3 жыл бұрын
Update: Flutter released version 2.5 and upgrading to it made things work normally again.
@learningcurious5845
@learningcurious5845 2 жыл бұрын
after converting to apk release file installing on an android phone not working not retreiving the API. but working fine in emulator. what is the reason anybody??
@marcinbiaasek9776
@marcinbiaasek9776 2 жыл бұрын
4:15 lol ... "other"
Flutter Local Data Persistence - Shared Preferences
47:40
Johan Jurrius
Рет қаралды 6 М.
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 117 МЛН
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,6 МЛН
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 13 МЛН
Login UI using BLoC with Flutter | Day 21 - #30DaysOfFlutter
36:23
Laid Off, AI is Coming
13:06
Kilo Loco
Рет қаралды 3,5 М.
Top 70 Flutter Tips, Widgets & Packages
16:22
Flutter Mapp
Рет қаралды 128 М.
30 Programming Truths I know at 30 that I Wish I Knew at 20
17:41
Best 30 Flutter Widgets, Packages & Tips
5:11
Flutter Mapp
Рет қаралды 122 М.
Top 30 Flutter Tips and Tricks
6:50
Flutter Mapp
Рет қаралды 563 М.
Optimize Flutter App Performance: Effortlessly Cache API Data in Flutter
1:39:49
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 117 МЛН