mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[flutter] Upgraded to Flutter 3.16.0, fixes #2420
This commit is contained in:
parent
14089dba6a
commit
58887199ca
@ -27,10 +27,10 @@
|
|||||||
/// SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
/// SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
import 'package:spine_flutter/raw_image_provider.dart';
|
||||||
import 'package:spine_flutter/spine_flutter.dart';
|
import 'package:spine_flutter/spine_flutter.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/painting.dart' as painting;
|
import 'package:flutter/painting.dart' as painting;
|
||||||
import 'package:raw_image_provider/raw_image_provider.dart';
|
|
||||||
|
|
||||||
class DressUp extends StatefulWidget {
|
class DressUp extends StatefulWidget {
|
||||||
const DressUp({Key? key}) : super(key: key);
|
const DressUp({Key? key}) : super(key: key);
|
||||||
|
|||||||
@ -21,10 +21,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
|
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.2"
|
version: "1.18.0"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -37,26 +37,26 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cupertino_icons
|
||||||
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
|
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.6"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99
|
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "2.1.0"
|
||||||
flame:
|
flame:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flame
|
name: flame
|
||||||
sha256: "12db9de3cd31b86465b0c1ea173020fb71b15df424ca01b665fa5300b24864c8"
|
sha256: b6bb76224fc29fd5eea25d66cda6e322e3678bdedc1f65956c6151326a6a798b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.10.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -66,10 +66,10 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_lints
|
name: flutter_lints
|
||||||
sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
|
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "3.0.1"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -106,10 +106,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: lints
|
name: lints
|
||||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "3.0.0"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -122,18 +122,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
ordered_set:
|
ordered_set:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ordered_set
|
name: ordered_set
|
||||||
sha256: "3fedcc9121b3ba24c0a84f32da2989c42e36c159b73feadbc2f402dc55966b81"
|
sha256: "3858c7d84619edfab87c3e367584648020903187edb70b52697646f4b2a93022"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.1"
|
version: "5.0.2"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -169,7 +169,7 @@ packages:
|
|||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "4.1.4"
|
version: "4.1.7"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -206,10 +206,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web
|
name: web
|
||||||
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
|
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.4-beta"
|
version: "0.3.0"
|
||||||
web_ffi_fork:
|
web_ffi_fork:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -219,5 +219,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.4"
|
version: "0.7.4"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.1.0-185.0.dev <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
flutter: ">=3.10.5"
|
flutter: ">=3.16.0"
|
||||||
|
|||||||
@ -5,7 +5,7 @@ version: 1.0.0+1
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.6 <4.0.0'
|
sdk: '>=2.17.6 <4.0.0'
|
||||||
flutter: ">=3.10.5"
|
flutter: ">=3.16.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@ -13,12 +13,12 @@ dependencies:
|
|||||||
|
|
||||||
spine_flutter:
|
spine_flutter:
|
||||||
path: ../
|
path: ../
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.6
|
||||||
flame: ^1.4.0
|
flame: ^1.10.1
|
||||||
raw_image_provider: ^0.2.0
|
raw_image_provider: ^0.2.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^3.0.1
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
120
spine-flutter/lib/raw_image_provider.dart
Normal file
120
spine-flutter/lib/raw_image_provider.dart
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Yrom Wang
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/painting.dart';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
|
||||||
|
/// Decodes the given [image] (raw image pixel data) as an image ('dart:ui')
|
||||||
|
class RawImageProvider extends ImageProvider<_RawImageKey> {
|
||||||
|
final RawImageData image;
|
||||||
|
final double? scale;
|
||||||
|
final int? targetWidth;
|
||||||
|
final int? targetHeight;
|
||||||
|
RawImageProvider(
|
||||||
|
this.image, {
|
||||||
|
this.scale = 1.0,
|
||||||
|
this.targetWidth,
|
||||||
|
this.targetHeight,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ImageStreamCompleter loadImage(_RawImageKey key, ImageDecoderCallback decode) {
|
||||||
|
return MultiFrameImageStreamCompleter(
|
||||||
|
codec: _loadAsync(key),
|
||||||
|
scale: scale ?? 1.0,
|
||||||
|
debugLabel: 'RawImageProvider(${describeIdentity(key)})',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<_RawImageKey> obtainKey(ImageConfiguration configuration) {
|
||||||
|
return SynchronousFuture(image._obtainKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// see [ui.decodeImageFromPixels]
|
||||||
|
Future<ui.Codec> _loadAsync(_RawImageKey key) async {
|
||||||
|
assert(key == image._obtainKey());
|
||||||
|
// rgba8888 pixels
|
||||||
|
var buffer = await ui.ImmutableBuffer.fromUint8List(image.pixels);
|
||||||
|
|
||||||
|
final descriptor = ui.ImageDescriptor.raw(
|
||||||
|
buffer,
|
||||||
|
width: image.width,
|
||||||
|
height: image.height,
|
||||||
|
pixelFormat: image.pixelFormat,
|
||||||
|
);
|
||||||
|
assert(() {
|
||||||
|
debugPrint('ImageDescriptor: ${descriptor.width}x${descriptor.height}');
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
|
return descriptor.instantiateCodec(
|
||||||
|
targetWidth: targetWidth, targetHeight: targetHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RawImageKey {
|
||||||
|
final int w;
|
||||||
|
final int h;
|
||||||
|
final int format;
|
||||||
|
final Digest dataHash;
|
||||||
|
_RawImageKey(this.w, this.h, this.format, this.dataHash);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
|
||||||
|
return other is _RawImageKey &&
|
||||||
|
other.w == w &&
|
||||||
|
other.h == h &&
|
||||||
|
other.format == format &&
|
||||||
|
other.dataHash == dataHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return hashValues(w, h, format, dataHash.hashCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Raw pixels data of an image
|
||||||
|
class RawImageData {
|
||||||
|
final Uint8List pixels;
|
||||||
|
final int width;
|
||||||
|
final int height;
|
||||||
|
final ui.PixelFormat pixelFormat;
|
||||||
|
|
||||||
|
RawImageData(
|
||||||
|
this.pixels,
|
||||||
|
this.width,
|
||||||
|
this.height, {
|
||||||
|
this.pixelFormat = ui.PixelFormat.rgba8888,
|
||||||
|
});
|
||||||
|
|
||||||
|
_RawImageKey? _key;
|
||||||
|
_RawImageKey _obtainKey() {
|
||||||
|
return _key ??=
|
||||||
|
_RawImageKey(width, height, pixelFormat.index, md5.convert(pixels));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,11 +38,12 @@ import 'package:flutter/rendering.dart' as rendering;
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:raw_image_provider/raw_image_provider.dart';
|
|
||||||
|
|
||||||
import 'ffi_proxy.dart';
|
import 'ffi_proxy.dart';
|
||||||
import 'init.dart' if (dart.library.html) 'init_web.dart';
|
import 'init.dart' if (dart.library.html) 'init_web.dart';
|
||||||
import 'spine_flutter_bindings_generated.dart';
|
import 'spine_flutter_bindings_generated.dart';
|
||||||
|
import 'raw_image_provider.dart';
|
||||||
|
|
||||||
export 'spine_widget.dart';
|
export 'spine_widget.dart';
|
||||||
|
|
||||||
|
|||||||
@ -8,23 +8,23 @@ documentation: https://esotericsoftware.com/spine-flutter
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.6 <4.0.0'
|
sdk: '>=2.17.6 <4.0.0'
|
||||||
flutter: ">=3.10.5"
|
flutter: ">=3.16.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
ffi: ^2.0.1
|
ffi: ^2.1.0
|
||||||
web_ffi_fork: ^0.7.4
|
web_ffi_fork: ^0.7.4
|
||||||
inject_js: ^2.0.0
|
inject_js: ^2.0.0
|
||||||
js: ^0.6.5
|
js: ^0.6.5
|
||||||
meta: ^1.8.0
|
meta: ^1.10.0
|
||||||
http: ^1.1.0
|
http: ^1.1.0
|
||||||
path: ^1.8.2
|
path: ^1.8.2
|
||||||
raw_image_provider: ^0.2.0
|
crypto: ^3.0.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
ffigen: ^9.0.1
|
ffigen: ^10.0.0
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^3.0.1
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
plugin:
|
plugin:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user