File Storage

Learn to read and write files.

In this lesson, we’ll persist the cart data using disk files by combining the path_provider plugin with the dart:io library. You’ll work on the app below:

// Route constants
const String productsOverviewRoute = '/';
const String productDetailRoute = '/product-detail';
const String cartScreenRoute = '/cart-screen';
const String settingsScreenRoute = '/settings-screen';

// Prefs Constants
const prefStringKey = 'username';
const prefNumKey = 'phoneNumber';
const prefBoolKey = 'theme';
E-commerce app initial code

Adding dependencies

Add the path_provider plugin to the pubspec.yaml file. Locate # TODO-1: Add dependency and add the dependency shown below:

Press + to interact
path_provider: ^2.0.8

Note: Import the dependency ...