Skip to content

Commit 1bfa214

Browse files
committed
added: shared_preferences plugin to persist_key_value example
1 parent d49037f commit 1bfa214

File tree

7 files changed

+144
-95
lines changed

7 files changed

+144
-95
lines changed

persist_key_value/.idea/libraries/Dart_Packages.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

persist_key_value/.idea/libraries/Flutter_Plugins.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

persist_key_value/.idea/workspace.xml

Lines changed: 65 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

persist_key_value/ios/Podfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
def parse_KV_file(file, separator='=')
8+
file_abs_path = File.expand_path(file)
9+
if !File.exists? file_abs_path
10+
return [];
11+
end
12+
pods_ary = []
13+
skip_line_start_symbols = ["#", "/"]
14+
File.foreach(file_abs_path) { |line|
15+
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
16+
plugin = line.split(pattern=separator)
17+
if plugin.length == 2
18+
podname = plugin[0].strip()
19+
path = plugin[1].strip()
20+
podpath = File.expand_path("#{path}", file_abs_path)
21+
pods_ary.push({:name => podname, :path => podpath});
22+
else
23+
puts "Invalid plugin specification: #{line}"
24+
end
25+
}
26+
return pods_ary
27+
end
28+
29+
target 'Runner' do
30+
use_frameworks!
31+
32+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
33+
# referring to absolute paths on developers' machines.
34+
system('rm -rf .symlinks')
35+
system('mkdir -p .symlinks/plugins')
36+
37+
# Flutter Pods
38+
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
39+
if generated_xcode_build_settings.empty?
40+
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
41+
end
42+
generated_xcode_build_settings.map { |p|
43+
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
44+
symlink = File.join('.symlinks', 'flutter')
45+
File.symlink(File.dirname(p[:path]), symlink)
46+
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
47+
end
48+
}
49+
50+
# Plugin Pods
51+
plugin_pods = parse_KV_file('../.flutter-plugins')
52+
plugin_pods.map { |p|
53+
symlink = File.join('.symlinks', 'plugins', p[:name])
54+
File.symlink(p[:path], symlink)
55+
pod p[:name], :path => File.join(symlink, 'ios')
56+
}
57+
end
58+
59+
post_install do |installer|
60+
installer.pods_project.targets.each do |target|
61+
target.build_configurations.each do |config|
62+
config.build_settings['ENABLE_BITCODE'] = 'NO'
63+
end
64+
end
65+
end

persist_key_value/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
dev_dependencies:
1313
flutter_test:
1414
sdk: flutter
15+
shared_preferences: 0.4.2
1516

1617

1718
# For information on the generic Dart part of this file, see the

0 commit comments

Comments
 (0)