Skip to content

Commit 32eeace

Browse files
author
Atiqur Rahman
authored
feat(null-safety): Add null safety support
1 parent c6e178b commit 32eeace

29 files changed

+310
-414
lines changed

example/ios/Podfile

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,78 +10,32 @@ project 'Runner', {
1010
'Release' => :release,
1111
}
1212

13-
def parse_KV_file(file, separator='=')
14-
file_abs_path = File.expand_path(file)
15-
if !File.exists? file_abs_path
16-
return [];
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1717
end
18-
generated_key_values = {}
19-
skip_line_start_symbols = ["#", "/"]
20-
File.foreach(file_abs_path) do |line|
21-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22-
plugin = line.split(pattern=separator)
23-
if plugin.length == 2
24-
podname = plugin[0].strip()
25-
path = plugin[1].strip()
26-
podpath = File.expand_path("#{path}", file_abs_path)
27-
generated_key_values[podname] = podpath
28-
else
29-
puts "Invalid plugin specification: #{line}"
30-
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
3122
end
32-
generated_key_values
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
3324
end
3425

26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
3530
target 'Runner' do
3631
use_frameworks!
3732
use_modular_headers!
3833

39-
# Flutter Pod
40-
41-
copied_flutter_dir = File.join(__dir__, 'Flutter')
42-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48-
49-
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50-
unless File.exist?(generated_xcode_build_settings_path)
51-
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
52-
end
53-
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54-
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55-
56-
unless File.exist?(copied_framework_path)
57-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58-
end
59-
unless File.exist?(copied_podspec_path)
60-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61-
end
62-
end
63-
64-
# Keep pod path relative so it can be checked into Podfile.lock.
65-
pod 'Flutter', :path => 'Flutter'
66-
67-
# Plugin Pods
68-
69-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70-
# referring to absolute paths on developers' machines.
71-
system('rm -rf .symlinks')
72-
system('mkdir -p .symlinks/plugins')
73-
plugin_pods = parse_KV_file('../.flutter-plugins')
74-
plugin_pods.each do |name, path|
75-
symlink = File.join('.symlinks', 'plugins', name)
76-
File.symlink(path, symlink)
77-
pod name, :path => File.join(symlink, 'ios')
78-
end
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7935
end
8036

8137
post_install do |installer|
8238
installer.pods_project.targets.each do |target|
83-
target.build_configurations.each do |config|
84-
config.build_settings['ENABLE_BITCODE'] = 'NO'
85-
end
39+
flutter_additional_ios_build_settings(target)
8640
end
8741
end

example/ios/Podfile.lock

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,34 @@
11
PODS:
22
- Flutter (1.0.0)
3-
- get_version (0.0.1):
4-
- Flutter
53
- nstack (0.0.1):
64
- Flutter
75
- package_info (0.0.1):
86
- Flutter
97
- shared_preferences (0.0.1):
108
- Flutter
11-
- shared_preferences_macos (0.0.1):
12-
- Flutter
13-
- shared_preferences_web (0.0.1):
14-
- Flutter
159

1610
DEPENDENCIES:
1711
- Flutter (from `Flutter`)
18-
- get_version (from `.symlinks/plugins/get_version/ios`)
1912
- nstack (from `.symlinks/plugins/nstack/ios`)
2013
- package_info (from `.symlinks/plugins/package_info/ios`)
2114
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
22-
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
23-
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
2415

2516
EXTERNAL SOURCES:
2617
Flutter:
2718
:path: Flutter
28-
get_version:
29-
:path: ".symlinks/plugins/get_version/ios"
3019
nstack:
3120
:path: ".symlinks/plugins/nstack/ios"
3221
package_info:
3322
:path: ".symlinks/plugins/package_info/ios"
3423
shared_preferences:
3524
:path: ".symlinks/plugins/shared_preferences/ios"
36-
shared_preferences_macos:
37-
:path: ".symlinks/plugins/shared_preferences_macos/ios"
38-
shared_preferences_web:
39-
:path: ".symlinks/plugins/shared_preferences_web/ios"
4025

4126
SPEC CHECKSUMS:
42-
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
43-
get_version: 2bc18c4e26a265571662cab5d38f8b50dc8c1c77
27+
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
4428
nstack: a7ebf31d8c387ec76d4bfe5eb494d3ac81756d92
4529
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
4630
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
47-
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
48-
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
4931

50-
PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a
32+
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
5133

52-
COCOAPODS: 1.8.4
34+
COCOAPODS: 1.10.1

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,12 @@
225225
buildActionMask = 2147483647;
226226
files = (
227227
);
228-
inputPaths = (
229-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
230-
"${PODS_ROOT}/../Flutter/Flutter.framework",
231-
"${BUILT_PRODUCTS_DIR}/get_version/get_version.framework",
232-
"${BUILT_PRODUCTS_DIR}/nstack/nstack.framework",
233-
"${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
234-
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
228+
inputFileListPaths = (
229+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
235230
);
236231
name = "[CP] Embed Pods Frameworks";
237-
outputPaths = (
238-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
239-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/get_version.framework",
240-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nstack.framework",
241-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
242-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
232+
outputFileListPaths = (
233+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
243234
);
244235
runOnlyForDeploymentPostprocessing = 0;
245236
shellPath = /bin/sh;
@@ -318,7 +309,6 @@
318309
/* Begin XCBuildConfiguration section */
319310
249021D3217E4FDB00AE95B9 /* Profile */ = {
320311
isa = XCBuildConfiguration;
321-
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
322312
buildSettings = {
323313
ALWAYS_SEARCH_USER_PATHS = NO;
324314
CLANG_ANALYZER_NONNULL = YES;
@@ -395,7 +385,6 @@
395385
};
396386
97C147031CF9000F007C117D /* Debug */ = {
397387
isa = XCBuildConfiguration;
398-
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
399388
buildSettings = {
400389
ALWAYS_SEARCH_USER_PATHS = NO;
401390
CLANG_ANALYZER_NONNULL = YES;
@@ -451,7 +440,6 @@
451440
};
452441
97C147041CF9000F007C117D /* Release */ = {
453442
isa = XCBuildConfiguration;
454-
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
455443
buildSettings = {
456444
ALWAYS_SEARCH_USER_PATHS = NO;
457445
CLANG_ANALYZER_NONNULL = YES;

example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata

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

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:nstack_example/nstack.dart';
2+
import 'nstack.dart';
33

44
void main() {
55
runApp(NStackWidget(child: MyApp()));

example/lib/nstack.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class _DefaultSection extends SectionKeyDelegate {
2121
const _DefaultSection(): super('default');
2222

2323
String get title => get('title', "NStack SDK Demo");
24+
String get test => get('test', "test");
2425
}
2526

2627
class _Test extends SectionKeyDelegate {
@@ -40,27 +41,26 @@ const _languages = [
4041
];
4142

4243
const _bundledTranslations = {
43-
'en-EN': r'''{"data":{"default":{"title":"NStack SDK Demo"},"test":{"testDollarSign":"$testing","testSingleQuotationMark":"'testing'","testDoubleQuotationMark":"\"testing\"","testMultipleLines":"testing\nmultiple\nlines"}},"meta":{"language":{"id":56,"name":"English","locale":"en-EN","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''',
44-
'de-AT': r'''{"data":{"default":{"title":"NStack SDK Demo"},"test":{"testDollarSign":"__testDollarSign","testSingleQuotationMark":"__testSingleQuotationMark","testDoubleQuotationMark":"__testDoubleQuotationMark","testMultipleLines":"__testMultipleLines"}},"meta":{"language":{"id":7,"name":"German (Austria)","locale":"de-AT","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''',
44+
'en-EN': r'''{"data":{"default":{"title":"NStack SDK Demo","test":"test"},"test":{"testDollarSign":"$testing","testSingleQuotationMark":"'testing'","testDoubleQuotationMark":"\"testing\"","testMultipleLines":"testing\nmultiple\nlines"}},"meta":{"language":{"id":56,"name":"English","locale":"en-EN","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''',
45+
'de-AT': r'''{"data":{"default":{"title":"NStack SDK Demo","test":"test"},"test":{"testDollarSign":"__testDollarSign","testSingleQuotationMark":"__testSingleQuotationMark","testDoubleQuotationMark":"__testDoubleQuotationMark","testMultipleLines":"__testMultipleLines"}},"meta":{"language":{"id":7,"name":"German (Austria)","locale":"de-AT","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''',
4546
};
4647

4748
final _nstack = NStack<Localization>(
4849
config: _config,
4950
localization: const Localization(),
5051
availableLanguages: _languages,
5152
bundledTranslations: _bundledTranslations,
52-
pickedLanguageLocale: null,
53+
pickedLanguageLocale: '',
5354
);
5455

5556
class NStackWidget extends InheritedWidget {
5657
final NStack<Localization> nstack = _nstack;
5758

58-
NStackWidget({Key key, @required Widget child})
59-
: assert(child != null),
60-
super(key: key, child: child);
59+
NStackWidget({Key? key, required Widget child})
60+
: super(key: key, child: child);
6161

6262
static NStack of(BuildContext context) =>
63-
context.dependOnInheritedWidgetOfExactType<NStackWidget>().nstack;
63+
context.dependOnInheritedWidgetOfExactType<NStackWidget>()!.nstack;
6464

6565
@override
6666
bool updateShouldNotify(NStackWidget oldWidget) =>
@@ -70,7 +70,7 @@ class NStackWidget extends InheritedWidget {
7070
class NStackInitWidget extends StatefulWidget {
7171
final Widget child;
7272

73-
const NStackInitWidget({Key key, Widget child})
73+
const NStackInitWidget({Key? key, required Widget child})
7474
: child = child,
7575
super(key: key);
7676

0 commit comments

Comments
 (0)