I have a web site built with flutter for web and currently, am trying to save to web local storage or cookie but can\'t seem to find any plugin or way to ar
shared_preferences dart package now supports local storage for the web from version 0.5.4.7+
Similar to shared preference on Android and iOS, the following is the code snippet for local storage on web
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart'; // rememeber to import shared_preferences: ^0.5.4+8
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: RaisedButton(
onPressed: _incrementCounter,
child: Text('Increment Counter'),
),
),
),
));
}
_incrementCounter() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
int counter = (prefs.getInt('counter') ?? 0) + 1;
print('Pressed $counter times.');
await prefs.setInt('counter', counter);
}