Skip to content

Commit e418554

Browse files
authored
Merge pull request #58 from fluttercandies/nnbd
Migrate to null safety
2 parents c813ca0 + a36f52e commit e418554

Some content is hidden

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

42 files changed

+395
-436
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
build/
88
.settings
9-
.idea/
9+
.idea/
10+
11+
.env

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"dart.flutterSdkPath": "/Volumes/Samsung-T5/sdk/flutter/fvm/1.17.0"
2+
"dart.flutterSdkPath": "/Users/jinglongcai/sdk/flutter/fvm/versions/beta"
33
}

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ android {
4141

4242
dependencies {
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
44-
implementation 'androidx.exifinterface:exifinterface:1.0.0'
44+
implementation 'androidx.exifinterface:exifinterface:1.3.2'
4545
implementation 'com.jaredrummler:truetypeparser-light:1.0.0'
4646
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
additional functionality it is fine to subclass or reimplement
77
FlutterApplication and put your custom class here. -->
88
<application
9-
android:name="io.flutter.app.FlutterApplication"
10-
android:label="flutter_image_editor_example"
11-
android:icon="@mipmap/ic_launcher">
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="flutter_image_editor_example">
1211
<activity
1312
android:name=".MainActivity"
14-
android:launchMode="singleTop"
15-
android:theme="@style/LaunchTheme"
1613
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1714
android:hardwareAccelerated="true"
15+
android:launchMode="singleTop"
16+
android:theme="@style/LaunchTheme"
1817
android:windowSoftInputMode="adjustResize">
1918
<!-- This keeps the window background of the activity showing
2019
until Flutter renders its first frame. It can be removed if
@@ -24,9 +23,13 @@
2423
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
2524
android:value="true" />
2625
<intent-filter>
27-
<action android:name="android.intent.action.MAIN"/>
28-
<category android:name="android.intent.category.LAUNCHER"/>
26+
<action android:name="android.intent.action.MAIN" />
27+
<category android:name="android.intent.category.LAUNCHER" />
2928
</intent-filter>
3029
</activity>
30+
31+
<meta-data
32+
android:name="flutterEmbedding"
33+
android:value="2" />
3134
</application>
3235
</manifest>
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package top.kikt.flutter_image_editor_example
22

3-
import android.os.Bundle
4-
import io.flutter.app.FlutterActivity
5-
import io.flutter.plugins.GeneratedPluginRegistrant
3+
import io.flutter.embedding.android.FlutterActivity
64

7-
class MainActivity: FlutterActivity() {
8-
override fun onCreate(savedInstanceState: Bundle?) {
9-
super.onCreate(savedInstanceState)
10-
GeneratedPluginRegistrant.registerWith(this)
11-
}
5+
class MainActivity : FlutterActivity() {
126
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.61'
2+
ext.kotlin_version = '1.4.30'
33
repositories {
44
maven {
55
url 'https://storage.flutter-io.cn/download.flutter.io'

example/ios/Flutter/Flutter.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#
22
# NOTE: This podspec is NOT to be published. It is only used as a local source!
3+
# This is a generated file; do not edit or check into version control.
34
#
45

56
Pod::Spec.new do |s|
67
s.name = 'Flutter'
78
s.version = '1.0.0'
89
s.summary = 'High-performance, high-fidelity mobile apps.'
9-
s.description = <<-DESC
10-
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
11-
DESC
1210
s.homepage = 'https://flutter.io'
1311
s.license = { :type => 'MIT' }
1412
s.author = { 'Flutter Dev Team' => '[email protected]' }
1513
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
1614
s.ios.deployment_target = '8.0'
17-
s.vendored_frameworks = 'Flutter.framework'
15+
# Framework linking is handled by Flutter tooling, not CocoaPods.
16+
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
17+
s.vendored_frameworks = 'path/to/nothing'
1818
end

example/ios/Podfile

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +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-
specPath = "#{path}/ios/#{name}.podspec"
76-
pod name,:path=>specPath
77-
end
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7835
end
7936

8037
post_install do |installer|
8138
installer.pods_project.targets.each do |target|
82-
target.build_configurations.each do |config|
83-
config.build_settings['ENABLE_BITCODE'] = 'NO'
84-
end
39+
flutter_additional_ios_build_settings(target)
8540
end
8641
end

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,12 @@
263263
);
264264
inputPaths = (
265265
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
266-
"${PODS_ROOT}/../Flutter/Flutter.framework",
267-
"${BUILT_PRODUCTS_DIR}/flutter_plugin_android_lifecycle/flutter_plugin_android_lifecycle.framework",
268266
"${BUILT_PRODUCTS_DIR}/image_editor/image_editor.framework",
269267
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
270268
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
271269
);
272270
name = "[CP] Embed Pods Frameworks";
273271
outputPaths = (
274-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
275-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_plugin_android_lifecycle.framework",
276272
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor.framework",
277273
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
278274
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",

example/lib/add_text_page.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AddTextPage extends StatefulWidget {
1616
}
1717

1818
class _AddTextPageState extends State<AddTextPage> {
19-
ImageProvider target;
19+
ImageProvider? target;
2020

2121
String get asset => R.ASSETS_ICON_PNG;
2222

@@ -48,7 +48,7 @@ class _AddTextPageState extends State<AddTextPage> {
4848
aspectRatio: 1,
4949
child: target != null
5050
? Image(
51-
image: target,
51+
image: target!,
5252
)
5353
: Container(),
5454
),
@@ -59,27 +59,27 @@ class _AddTextPageState extends State<AddTextPage> {
5959
mainAxisSize: MainAxisSize.max,
6060
mainAxisAlignment: MainAxisAlignment.center,
6161
children: <Widget>[
62-
RaisedButton(
62+
ElevatedButton(
6363
onPressed: () async {
6464
await addText(fontName);
6565
},
6666
child: const Text('add'),
6767
),
68-
RaisedButton(
68+
ElevatedButton(
6969
onPressed: () async {
7070
await addText('');
7171
},
7272
child: const Text('add use defaultFont'),
7373
),
7474
],
7575
),
76-
RaisedButton(
76+
ElevatedButton(
7777
child: Text('download and register font'),
7878
onPressed: () async {
7979
final aliFontUrl =
8080
'https://cdn.jsdelivr.net/gh/kikt-blog/ali_font@master/Alibaba-PuHuiTi-Medium.ttf';
8181

82-
final body = await http.get(aliFontUrl);
82+
final body = await http.get(Uri.parse(aliFontUrl));
8383

8484
final tmpDir = await pp.getTemporaryDirectory();
8585
final f = File(
@@ -119,11 +119,15 @@ class _AddTextPageState extends State<AddTextPage> {
119119
option.addOption(textOption);
120120

121121
final Uint8List u = await getAssetImage();
122-
final Uint8List result = await ImageEditor.editImage(
122+
final Uint8List? result = await ImageEditor.editImage(
123123
image: u,
124124
imageEditorOption: option,
125125
);
126126
print(option.toString());
127+
128+
if (result == null) {
129+
return;
130+
}
127131
target = MemoryImage(result);
128132
setState(() {});
129133
}

0 commit comments

Comments
 (0)