Update to ffi 0.3.0-nullsafety.1 (#3513)
ffi 0.3.0 supports the new memory allocation model in Dart 2.12.0-259 and later.
diff --git a/packages/path_provider/path_provider_windows/CHANGELOG.md b/packages/path_provider/path_provider_windows/CHANGELOG.md
index 24304e3..6190c39 100644
--- a/packages/path_provider/path_provider_windows/CHANGELOG.md
+++ b/packages/path_provider/path_provider_windows/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.0-nullsafety.2
+
+* Bump ffi dependency to 0.3.0-nullsafety.1
+
## 0.1.0-nullsafety.1
* Bump win32 dependency to latest version.
diff --git a/packages/path_provider/path_provider_windows/example/windows/flutter/CMakeLists.txt b/packages/path_provider/path_provider_windows/example/windows/flutter/CMakeLists.txt
index c7a8c76..744f08a 100644
--- a/packages/path_provider/path_provider_windows/example/windows/flutter/CMakeLists.txt
+++ b/packages/path_provider/path_provider_windows/example/windows/flutter/CMakeLists.txt
@@ -91,6 +91,7 @@
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
+ VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
diff --git a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart
index c104343..c88e10a 100644
--- a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart
+++ b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart
@@ -28,17 +28,17 @@
}
const kEnUsLanguageCode = '040904e4';
final keyPath = TEXT('\\StringFileInfo\\$kEnUsLanguageCode\\$key');
- final length = allocate<Uint32>();
- final valueAddress = allocate<Pointer<Utf16>>();
+ final length = calloc<Uint32>();
+ final valueAddress = calloc<Pointer<Utf16>>();
try {
if (VerQueryValue(versionInfo, keyPath, valueAddress, length) == 0) {
return null;
}
return valueAddress.value.unpackString(length.value);
} finally {
- free(keyPath);
- free(length);
- free(valueAddress);
+ calloc.free(keyPath);
+ calloc.free(length);
+ calloc.free(valueAddress);
}
}
}
@@ -54,7 +54,7 @@
/// This is typically the same as the TMP environment variable.
@override
Future<String?> getTemporaryPath() async {
- final buffer = allocate<Uint16>(count: MAX_PATH + 1).cast<Utf16>();
+ final buffer = calloc<Uint16>(MAX_PATH + 1).cast<Utf16>();
String path;
try {
@@ -82,7 +82,7 @@
return Future.value(path);
} finally {
- free(buffer);
+ calloc.free(buffer);
}
}
@@ -115,7 +115,7 @@
/// folderID is a GUID that represents a specific known folder ID, drawn from
/// [WindowsKnownFolder].
Future<String> getPath(String folderID) {
- final pathPtrPtr = allocate<Pointer<Utf16>>();
+ final pathPtrPtr = calloc<Pointer<Utf16>>();
final Pointer<GUID> knownFolderID = calloc<GUID>()..ref.setGUID(folderID);
try {
@@ -135,8 +135,8 @@
final path = pathPtrPtr.value.unpackString(MAX_PATH);
return Future.value(path);
} finally {
- free(pathPtrPtr);
- free(knownFolderID);
+ calloc.free(pathPtrPtr);
+ calloc.free(knownFolderID);
}
}
@@ -155,8 +155,8 @@
String? productName;
final Pointer<Utf16> moduleNameBuffer =
- allocate<Uint16>(count: MAX_PATH + 1).cast<Utf16>();
- final Pointer<Uint32> unused = allocate<Uint32>();
+ calloc<Uint16>(MAX_PATH + 1).cast<Utf16>();
+ final Pointer<Uint32> unused = calloc<Uint32>();
Pointer<Uint8>? infoBuffer;
try {
// Get the module name.
@@ -169,10 +169,10 @@
// From that, load the VERSIONINFO resource
int infoSize = GetFileVersionInfoSize(moduleNameBuffer, unused);
if (infoSize != 0) {
- infoBuffer = allocate<Uint8>(count: infoSize);
+ infoBuffer = calloc<Uint8>(infoSize);
if (GetFileVersionInfo(moduleNameBuffer, 0, infoSize, infoBuffer) ==
0) {
- free(infoBuffer);
+ calloc.free(infoBuffer);
infoBuffer = null;
}
}
@@ -191,10 +191,10 @@
? path.join(companyName, productName)
: productName;
} finally {
- free(moduleNameBuffer);
- free(unused);
+ calloc.free(moduleNameBuffer);
+ calloc.free(unused);
if (infoBuffer != null) {
- free(infoBuffer);
+ calloc.free(infoBuffer);
}
}
}
diff --git a/packages/path_provider/path_provider_windows/pubspec.yaml b/packages/path_provider/path_provider_windows/pubspec.yaml
index 5780006..922594a 100644
--- a/packages/path_provider/path_provider_windows/pubspec.yaml
+++ b/packages/path_provider/path_provider_windows/pubspec.yaml
@@ -1,7 +1,7 @@
name: path_provider_windows
description: Windows implementation of the path_provider plugin
homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_windows
-version: 0.1.0-nullsafety.1
+version: 0.1.0-nullsafety.2
flutter:
plugin:
@@ -16,8 +16,8 @@
path: ^1.8.0-nullsafety.3
flutter:
sdk: flutter
- ffi: ^0.2.0-nullsafety.1
- win32: ^2.0.0-nullsafety.9
+ ffi: '>=0.3.0-nullsafety.1 <2.0.0'
+ win32: ^2.0.0-nullsafety.10
dev_dependencies:
flutter_test:
@@ -25,5 +25,6 @@
pedantic: ^1.10.0-nullsafety.3
environment:
- sdk: '>=2.12.0-0 <3.0.0'
+ sdk: '>=2.12.0-259.8.beta <3.0.0'
flutter: ">=1.12.13+hotfix.4"
+