Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lesnitsky/flutter_localstorage
📦 LocalStorage for Flutter
https://github.com/lesnitsky/flutter_localstorage
dart flutter flutter-package json-storage localstorage storage
Last synced: 5 days ago
JSON representation
📦 LocalStorage for Flutter
- Host: GitHub
- URL: https://github.com/lesnitsky/flutter_localstorage
- Owner: lesnitsky
- License: mit
- Created: 2018-09-21T00:41:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T13:36:05.000Z (6 months ago)
- Last Synced: 2025-01-10T20:04:40.142Z (12 days ago)
- Topics: dart, flutter, flutter-package, json-storage, localstorage, storage
- Language: C++
- Homepage:
- Size: 702 KB
- Stars: 299
- Watchers: 9
- Forks: 67
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# LocalStorage
[LocalStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) for Flutter.
> [!IMPORTANT]
> LocalStorage is not intended to store large amounts or sensitive data.[](https://twitter.com/lesnitsky_dev)
[](https://github.com/lesnitsky/flutter_localstorage)## Installation
```sh
flutter pub add localstorage
```or add dependency to `pubspec.yaml` manually
```yaml
dependencies:
localstorage: ^5.0.0
```## API docs
[LocalStorage API documentation](https://pub.dev/documentation/localstorage/latest/localstorage/LocalStorage-class.html)
## Usage
```dart
import 'package:flutter/material.dart';
import 'package:localstorage/localstorage.dart';late final ValueNotifier notifier;
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await initLocalStorage();notifier = ValueNotifier(int.parse(localStorage.getItem('counter') ?? '0'));
notifier.addListener(() {
localStorage.setItem('counter', notifier.value.toString());
});runApp(const MyApp());
}class MyApp extends StatelessWidget {
const MyApp({super.key});@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: ValueListenableBuilder(
valueListenable: notifier,
builder: (context, value, child) {
return Text('Pressed $value times');
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
notifier.value++;
},
child: const Icon(Icons.add),
),
),
);
}
}
```## License
MIT
[](https://twitter.com/lesnitsky_dev)
[](https://github.com/lesnitsky/flutter_localstorage)