Posts

Showing posts with the label Dart

Flutter Shared Preferences And Settings Menu Demo

Image
While Android/Java is super easy to use Shared Preferences, Flutter/Dart's Shared_Preferences is not that straightforward. When I was learning Shared Preferences, I did a lot of Google searching. Most of what I found is talking about making separate class file or creating tons of setter/getter functions.  I was wondering if I can code it differently. So I tried my own simply way.  Here is what I did. First add dependency to file pubspec.yaml. dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.3 # TODO: Add dependency shared_preferences: ^0.5.10 And "Pub Get" it. Then import package. import 'package:flutter/material.dart'; //TODO: import package import 'package:shared_preferences/shared_preferences.dart';   Three Steps To Use SharedPreferences In Flutter/Dart 1. Initialization The key to use Flu...