VOOZH about

URL: https://www.geeksforgeeks.org/flutter/how-to-setup-sharedpreferences-in-flutter/

⇱ How to Setup SharedPreferences in Flutter? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Setup SharedPreferences in Flutter?

Last Updated : 22 Mar, 2022

SharedPreferences is a package that enables the Application to store a small amount of data in your local storage. Like user name, id, etc. You don't need other databases for it like SQLITE, FIREBASE, etc. So in this article, we will see How to install the Shared Preferences package in Dart/Flutter and How to use it in Flutter. Installation of packages in flutter is pretty easy. Just follow the steps below.

Step by Step Implementation

Step 1. Go to the pubspec.yaml file in your project.

👁 Image

Step 2. Now add your package under the dependencies section.

👁 Image
 

Note: Make sure you have provided the correct Indentation.

Step 3. Now In the Top right click on the get packages. This will add your package.

👁 Image

Step 4. Confirmation of Installation

👁 Image
 

If you get the exit code 0, that's means you successfully added your package.

Step 5. Now finally import the package into your working file.

import 'package:shared_preferences/shared_preferences.dart';

Hope you successfully install the SharedPreferences Package in your flutter project.

Comment
Article Tags:

Explore