Skip to content

Commit 195ed3d

Browse files
franciscojma86Egor
authored andcommitted
[shared_preferences] Adds macOS support with example app (flutter#2385)
1 parent 79bd3fd commit 195ed3d

File tree

83 files changed

+2783
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2783
-6
lines changed

packages/shared_preferences/shared_preferences/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.4+10
2+
3+
* Adds a `shared_preferences_macos` package.
4+
15
## 0.5.4+9
26

37
* Remove the deprecated `author:` field from pubspec.yaml

packages/shared_preferences/shared_preferences/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: shared_preferences
22
description: Flutter plugin for reading and writing simple key-value pairs.
33
Wraps NSUserDefaults on iOS and SharedPreferences on Android.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences
5-
version: 0.5.4+9
5+
version: 0.5.4+10
66

77
flutter:
88
plugin:
@@ -29,4 +29,4 @@ dev_dependencies:
2929

3030
environment:
3131
sdk: ">=2.0.0-dev.28.0 <3.0.0"
32-
flutter: ">=1.10.0 <2.0.0"
32+
flutter: ">=1.12.8 <2.0.0"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* Initial open source release.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2017, the Flutter project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# shared_preferences_macos
2+
3+
The macos implementation of [`shared_preferences`][1].
4+
5+
## Usage
6+
7+
### Import the package
8+
9+
To use this plugin in your Flutter app, simply add it as a dependency in
10+
your `pubspec.yaml` alongside the base `shared_preferences` plugin.
11+
12+
_(This is only temporary: in the future we hope to make this package an
13+
"endorsed" implementation of `shared_preferences`, so that it is automatically
14+
included in your Flutter app when you depend on `package:shared_preferences`.)_
15+
16+
This is what the above means to your `pubspec.yaml`:
17+
18+
```yaml
19+
...
20+
dependencies:
21+
...
22+
shared_preferences: ^0.5.4+8
23+
shared_preferences_macos: ^0.1.0
24+
...
25+
```
26+
27+
### Use the plugin
28+
29+
Once you have the `shared_preferences_macos` dependency in your pubspec, you should
30+
be able to use `package:shared_preferences` as normal.
31+
32+
[1]: ../shared_preferences/shared_preferences_macos
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# shared_preferences_example
2+
3+
Demonstrates how to use the shared_preferences plugin.
4+
5+
## Getting Started
6+
7+
For help getting started with Flutter, view our online
8+
[documentation](http://flutter.io/).
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
7+
}
8+
9+
def flutterRoot = localProperties.getProperty('flutter.sdk')
10+
if (flutterRoot == null) {
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
apply plugin: 'com.android.application'
25+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26+
27+
android {
28+
compileSdkVersion 28
29+
30+
lintOptions {
31+
disable 'InvalidPackage'
32+
}
33+
34+
defaultConfig {
35+
applicationId "io.flutter.plugins.sharedpreferencesexample"
36+
minSdkVersion 16
37+
targetSdkVersion 28
38+
versionCode flutterVersionCode.toInteger()
39+
versionName flutterVersionName
40+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
41+
}
42+
43+
buildTypes {
44+
release {
45+
// TODO: Add your own signing config for the release build.
46+
// Signing with the debug keys for now, so `flutter run --release` works.
47+
signingConfig signingConfigs.debug
48+
}
49+
}
50+
}
51+
52+
flutter {
53+
source '../..'
54+
}
55+
56+
dependencies {
57+
testImplementation 'junit:junit:4.12'
58+
androidTestImplementation 'androidx.test:runner:1.1.1'
59+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
60+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.sharedpreferencesexample">
3+
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
6+
<application android:name="io.flutter.app.FlutterApplication" android:label="shared_preferences_example" android:icon="@mipmap/ic_launcher">
7+
<activity android:name=".EmbeddingV1Activity"
8+
android:launchMode="singleTop"
9+
android:theme="@android:style/Theme.Black.NoTitleBar"
10+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
11+
android:hardwareAccelerated="true"
12+
android:windowSoftInputMode="adjustResize">
13+
</activity>
14+
<activity android:name=".MainActivity"
15+
android:theme="@android:style/Theme.Black.NoTitleBar"
16+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
17+
android:hardwareAccelerated="true"
18+
android:windowSoftInputMode="adjustResize">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN"/>
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.sharedpreferencesexample;
6+
7+
import android.os.Bundle;
8+
import io.flutter.app.FlutterActivity;
9+
import io.flutter.plugins.GeneratedPluginRegistrant;
10+
11+
public class EmbeddingV1Activity extends FlutterActivity {
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
GeneratedPluginRegistrant.registerWith(this);
17+
}
18+
}

0 commit comments

Comments
 (0)