https://github.com/yingzi-technology/yingzi_flutter_shared_preferences
Flutter存储插件:用法和shared_preferences完全一样;不同于shared_preferences,本插件并没有使用默认的存储空间,防止默认的存储空间太过庞大。
https://github.com/yingzi-technology/yingzi_flutter_shared_preferences
cache dart flutter
Last synced: 3 months ago
JSON representation
Flutter存储插件:用法和shared_preferences完全一样;不同于shared_preferences,本插件并没有使用默认的存储空间,防止默认的存储空间太过庞大。
- Host: GitHub
- URL: https://github.com/yingzi-technology/yingzi_flutter_shared_preferences
- Owner: Yingzi-Technology
- License: bsd-3-clause
- Created: 2022-05-07T06:02:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-07T06:21:54.000Z (about 3 years ago)
- Last Synced: 2025-01-17T08:20:15.921Z (4 months ago)
- Topics: cache, dart, flutter
- Language: Dart
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# YZ Shared preferences plugin
A plugin modified basing on [shared_preferences](https://github.com/flutter/plugins/tree/main/packages/shared_preferences)
User the special NSUserDefaults on iOS and macOS, SharedPreferences on Android instead of default.
不同于 [shared_preferences](https://github.com/flutter/plugins/tree/main/packages/shared_preferences),本插件并没有使用默认的存储空间,防止默认的存储空间因为共用的原因太过庞大。## Usage
To use this plugin, add `yshared_preferences` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels).### Example
``` dart
import 'package:flutter/material.dart';
import 'package:yshared_preferences/shared_preferences.dart';void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: RaisedButton(
onPressed: _incrementCounter,
child: Text('Increment Counter'),
),
),
),
));
}_incrementCounter() async {
YSharedPreferences prefs = await YSharedPreferences.getInstance();
int counter = (prefs.getInt('counter') ?? 0) + 1;
print('Pressed $counter times.');
await prefs.setInt('counter', counter);
}
```### Testing
You can populate `YSharedPreferences` with initial values in your tests by running this code:
```dart
YSharedPreferences.setMockInitialValues (Map values);
```