Skip to content
Permalink
Browse files

fix inconsistent return format

Closes #9
  • Loading branch information...
lesnitsky committed May 14, 2019
1 parent d3696f2 commit e4b2c732f79e2b132fb6f9bf8baccad9d4f38923
@@ -1,4 +1,10 @@
## 2.0.0

- fix inconsitent return format of `getItem`. It now always returns `JsonEncodable` representation of an item
- add optional `toEncodable` arg to `setItem`

## 1.3.1

- update `README.md` documentation
- bump `package_provider` dependency to address `getApplicationSupportDirectory`
- fix `noSuchMethodError` in `_flush`
@@ -9,7 +9,7 @@ Add dependency to `pubspec.yaml`
```yaml
dependencies:
...
localstorage: ^1.3.1
localstorage: ^2.0.0
```

Run in your terminal
@@ -0,0 +1,22 @@
PODS:
- Flutter (1.0.0)
- path_provider (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `.symlinks/flutter/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)

EXTERNAL SOURCES:
Flutter:
:path: ".symlinks/flutter/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"

SPEC CHECKSUMS:
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
path_provider: 09407919825bfe3c2deae39453b7a5b44f467873

PODFILE CHECKSUM: 1e5af4103afd21ca5ead147d7b81d06f494f51a2

COCOAPODS: 1.5.3
@@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
2A8C367AB0FCE292419AB198 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 042963D1A9BC435207F70EE6 /* libPods-Runner.a */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -38,9 +38,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
042963D1A9BC435207F70EE6 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -64,16 +64,31 @@
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
2A8C367AB0FCE292419AB198 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
7C7AC5554A5CA24C3D4B9D27 /* Pods */ = {
isa = PBXGroup;
children = (
);
name = Pods;
sourceTree = "<group>";
};
87FA88A932B7753C879E5F98 /* Frameworks */ = {
isa = PBXGroup;
children = (
042963D1A9BC435207F70EE6 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
@@ -90,7 +105,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
7C7AC5554A5CA24C3D4B9D27 /* Pods */,
87FA88A932B7753C879E5F98 /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -133,12 +149,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
E70806446AE41E65FFABF54A /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
1B9C247026541530D3B666FB /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -190,14 +208,35 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1B9C247026541530D3B666FB /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -226,6 +265,28 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
E70806446AE41E65FFABF54A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
@@ -52,7 +52,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.3.1"
version: "2.0.0"
matcher:
dependency: transitive
description:
@@ -88,9 +88,18 @@ class LocalStorage {
return _data[key];
}

/// Saves item by key to a storage. Value should be json encodable (`json.encode()` is called under the hood).
Future<void> setItem(String key, value) async {
_data[key] = value;
/// Saves item by [key] to a storage. Value should be json encodable (`json.encode()` is called under the hood).
/// After item was set to storage, consecutive [getItem] will return `json` representation of this item
/// if [toEncodable] is provided, it is called before setting item to storage
/// otherwise `value.toJson()` is called
Future<void> setItem(
String key,
value, [
Object toEncodable(Object nonEncodable),
]) async {
_data[key] = json.decode(
json.encode(toEncodable != null ? toEncodable(value) : value),
);

return _attemptFlush();
}
@@ -1,6 +1,6 @@
name: localstorage
description: Simple json file-based storage fo flutter. Alternative to react-native AsyncStorage
version: 1.3.1
version: 2.0.0
author: Andrei Lesnitsky <andrei.lesnitsky@gmail.com>
homepage: https://github.com/lesnitsky/flutter_localstorage

1 comment on commit e4b2c73

@AppleEducate

This comment has been minimized.

Copy link
Contributor

commented on e4b2c73 May 14, 2019

Very nice!

Please sign in to comment.
You can’t perform that action at this time.