diff --git a/.github/workflows/dart.yaml b/.github/workflows/dart.yaml index f6a4ea5..6cd5c4d 100644 --- a/.github/workflows/dart.yaml +++ b/.github/workflows/dart.yaml @@ -14,7 +14,11 @@ permissions: read-all jobs: analyze: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + sdk: [dev, stable] steps: # These are the latest versions of the github actions; dependabot will @@ -22,7 +26,7 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: - sdk: dev + sdk: ${{ matrix.sdk }} - name: Install dependencies run: dart pub get @@ -39,7 +43,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - sdk: [dev] + sdk: [dev, stable] steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b4b62..9acca14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0 + +- Lower SDK lower bound to 3.0.0. + ## 0.1.0 - Initial version. diff --git a/lib/mailbox.dart b/lib/mailbox.dart index d7a2796..0871a7c 100644 --- a/lib/mailbox.dart +++ b/lib/mailbox.dart @@ -103,11 +103,22 @@ class Mailbox { static final _emptyResponse = Uint8List(0); static Uint8List _toList(Pointer buffer, int length) { - return length == 0 - ? _emptyResponse - // We have to ignore sdk_version_since warning due to dartbug.com/53142. - // ignore: sdk_version_since - : buffer.asTypedList(length, finalizer: malloc.nativeFree); + if (length == 0) { + return _emptyResponse; + } + + // TODO: remove feature detection once 3.1 becomes stable. + // ignore: omit_local_variable_types + final Uint8List Function(int) asTypedList = buffer.asTypedList; + if (asTypedList is Uint8List Function(int, + {Pointer finalizer})) { + return asTypedList(length, finalizer: malloc.nativeFree); + } + + final result = Uint8List(length); + result.setRange(0, length, buffer.asTypedList(length)); + malloc.free(buffer); + return result; } static Pointer _toBuffer(Uint8List list) { diff --git a/pubspec.yaml b/pubspec.yaml index b1d3f7d..e16317f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: native_synchronization description: Low level synchronization primitives built on dart:ffi. -version: 0.1.0 +version: 0.2.0 repository: https://github.com/dart-lang/native_synchronization environment: - sdk: ">=3.1.0-348.0.dev <4.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: ffi: ^2.1.0