mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[flutter] Formatting.
This commit is contained in:
parent
1cf95f49d2
commit
ef3403d8ba
@ -1,2 +1,3 @@
|
||||
export 'dart:ffi' if (dart.library.html) 'package:web_ffi_fork/web_ffi.dart';
|
||||
|
||||
export 'package:ffi/ffi.dart' if (dart.library.html) 'package:web_ffi_fork/src/ffi/utf8.dart';
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
const String _libName = 'esotericsoftware_spine_flutter';
|
||||
|
||||
@ -4,6 +4,7 @@ import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:flutter/material.dart' as material;
|
||||
import 'package:flutter/rendering.dart' as rendering;
|
||||
import 'package:flutter/services.dart';
|
||||
@ -11,12 +12,11 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:raw_image_provider/raw_image_provider.dart';
|
||||
|
||||
import 'spine_flutter_bindings_generated.dart';
|
||||
import 'ffi_proxy.dart';
|
||||
import 'init.dart' if (dart.library.html) 'init_web.dart';
|
||||
import 'spine_flutter_bindings_generated.dart';
|
||||
|
||||
export 'spine_widget.dart';
|
||||
import 'init.dart' if (dart.library.html) 'init_web.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
late SpineFlutterBindings _bindings;
|
||||
late Allocator _allocator;
|
||||
@ -94,8 +94,7 @@ class Atlas {
|
||||
final Image image = frameInfo.image;
|
||||
atlasPages.add(image);
|
||||
atlasPagePaints.add(Paint()
|
||||
..shader = ImageShader(image, TileMode.clamp, TileMode.clamp, Matrix4.identity().storage,
|
||||
filterQuality: FilterQuality.high)
|
||||
..shader = ImageShader(image, TileMode.clamp, TileMode.clamp, Matrix4.identity().storage, filterQuality: FilterQuality.high)
|
||||
..isAntiAlias = true);
|
||||
}
|
||||
|
||||
@ -610,10 +609,7 @@ class BoneData {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_bone_data_get_color(_data);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -648,8 +644,7 @@ class Bone {
|
||||
_bindings.spine_bone_update_world_transform(_bone);
|
||||
}
|
||||
|
||||
void updateWorldTransformWith(
|
||||
double x, double y, double rotation, double scaleX, double scaleY, double shearX, double shearY) {
|
||||
void updateWorldTransformWith(double x, double y, double rotation, double scaleX, double scaleY, double shearX, double shearY) {
|
||||
_bindings.spine_bone_update_world_transform_with(_bone, x, y, rotation, scaleX, scaleY, shearX, shearY);
|
||||
}
|
||||
|
||||
@ -920,10 +915,7 @@ class SlotData {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_slot_data_get_color(_data);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -933,10 +925,7 @@ class SlotData {
|
||||
|
||||
Color getDarkColor() {
|
||||
final color = _bindings.spine_slot_data_get_dark_color(_data);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1000,10 +989,7 @@ class Slot {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_slot_get_color(_slot);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1013,10 +999,7 @@ class Slot {
|
||||
|
||||
Color getDarkColor() {
|
||||
final color = _bindings.spine_slot_get_dark_color(_slot);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1339,10 +1322,7 @@ class RegionAttachment extends Attachment<spine_region_attachment> {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_region_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1451,10 +1431,7 @@ class MeshAttachment extends VertexAttachment<spine_mesh_attachment> {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_mesh_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1527,10 +1504,7 @@ class ClippingAttachment extends VertexAttachment<spine_clipping_attachment> {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_clipping_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1544,10 +1518,7 @@ class BoundingBoxAttachment extends VertexAttachment<spine_bounding_box_attachme
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_bounding_box_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1583,10 +1554,7 @@ class PathAttachment extends VertexAttachment<spine_path_attachment> {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_path_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1635,10 +1603,7 @@ class PointAttachment extends Attachment<spine_point_attachment> {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_point_attachment_get_color(_attachment);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -1675,8 +1640,7 @@ class Skin {
|
||||
|
||||
void setAttachment(int slotIndex, String name, Attachment? attachment) {
|
||||
final nativeName = name.toNativeUtf8(allocator: _allocator);
|
||||
_bindings.spine_skin_set_attachment(
|
||||
_skin, slotIndex, nativeName.cast(), attachment == null ? nullptr : attachment._attachment.cast());
|
||||
_bindings.spine_skin_set_attachment(_skin, slotIndex, nativeName.cast(), attachment == null ? nullptr : attachment._attachment.cast());
|
||||
_allocator.free(nativeName);
|
||||
}
|
||||
|
||||
@ -1710,8 +1674,12 @@ class Skin {
|
||||
for (int i = 0; i < numEntries; i++) {
|
||||
final entry = _bindings.spine_skin_entries_get_entry(entries, i);
|
||||
Pointer<Utf8> name = _bindings.spine_skin_entry_get_name(entry).cast();
|
||||
result.add(SkinEntry(_bindings.spine_skin_entry_get_slot_index(entry), name.toDartString(),
|
||||
_bindings.spine_skin_entry_get_attachment(entry).address == nullptr.address ? null : Attachment._toSubclass(_bindings.spine_skin_entry_get_attachment(entry))));
|
||||
result.add(SkinEntry(
|
||||
_bindings.spine_skin_entry_get_slot_index(entry),
|
||||
name.toDartString(),
|
||||
_bindings.spine_skin_entry_get_attachment(entry).address == nullptr.address
|
||||
? null
|
||||
: Attachment._toSubclass(_bindings.spine_skin_entry_get_attachment(entry))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -2404,8 +2372,7 @@ class Skeleton {
|
||||
Attachment? getAttachmentByName(String slotName, String attachmentName) {
|
||||
final slotNameNative = slotName.toNativeUtf8(allocator: _allocator);
|
||||
final attachmentNameNative = attachmentName.toNativeUtf8(allocator: _allocator);
|
||||
final attachment =
|
||||
_bindings.spine_skeleton_get_attachment_by_name(_skeleton, slotNameNative.cast(), attachmentNameNative.cast());
|
||||
final attachment = _bindings.spine_skeleton_get_attachment_by_name(_skeleton, slotNameNative.cast(), attachmentNameNative.cast());
|
||||
_allocator.free(slotNameNative);
|
||||
_allocator.free(attachmentNameNative);
|
||||
if (attachment.address == nullptr.address) return null;
|
||||
@ -2460,11 +2427,8 @@ class Skeleton {
|
||||
/// @param outVertexBuffer Reference to hold a Vector of floats. This method will assign it with new floats as needed.
|
||||
Bounds getBounds() {
|
||||
final nativeBounds = _bindings.spine_skeleton_get_bounds(_skeleton);
|
||||
final bounds = Bounds(
|
||||
_bindings.spine_bounds_get_x(nativeBounds),
|
||||
_bindings.spine_bounds_get_y(nativeBounds),
|
||||
_bindings.spine_bounds_get_width(nativeBounds),
|
||||
_bindings.spine_bounds_get_height(nativeBounds));
|
||||
final bounds = Bounds(_bindings.spine_bounds_get_x(nativeBounds), _bindings.spine_bounds_get_y(nativeBounds),
|
||||
_bindings.spine_bounds_get_width(nativeBounds), _bindings.spine_bounds_get_height(nativeBounds));
|
||||
_allocator.free(nativeBounds);
|
||||
return bounds;
|
||||
}
|
||||
@ -2549,10 +2513,7 @@ class Skeleton {
|
||||
|
||||
Color getColor() {
|
||||
final color = _bindings.spine_skeleton_get_color(_skeleton);
|
||||
return Color(
|
||||
_bindings.spine_color_get_r(color),
|
||||
_bindings.spine_color_get_g(color),
|
||||
_bindings.spine_color_get_b(color),
|
||||
return Color(_bindings.spine_color_get_r(color), _bindings.spine_color_get_g(color), _bindings.spine_color_get_b(color),
|
||||
_bindings.spine_color_get_a(color));
|
||||
}
|
||||
|
||||
@ -3154,16 +3115,14 @@ class AnimationState {
|
||||
/// after AnimationState.Dispose.
|
||||
TrackEntry setAnimationByName(int trackIndex, String animationName, bool loop) {
|
||||
final animation = animationName.toNativeUtf8(allocator: _allocator);
|
||||
final entry =
|
||||
_bindings.spine_animation_state_set_animation_by_name(_state, trackIndex, animation.cast(), loop ? -1 : 0);
|
||||
final entry = _bindings.spine_animation_state_set_animation_by_name(_state, trackIndex, animation.cast(), loop ? -1 : 0);
|
||||
_allocator.free(animation);
|
||||
if (entry.address == nullptr.address) throw Exception("Couldn't set animation $animationName");
|
||||
return TrackEntry._(entry, this);
|
||||
}
|
||||
|
||||
TrackEntry setAnimation(int trackIndex, Animation animation, bool loop) {
|
||||
final entry =
|
||||
_bindings.spine_animation_state_set_animation(_state, trackIndex, animation._animation, loop ? -1 : 0);
|
||||
final entry = _bindings.spine_animation_state_set_animation(_state, trackIndex, animation._animation, loop ? -1 : 0);
|
||||
if (entry.address == nullptr.address) throw Exception("Couldn't set animation ${animation.getName()}");
|
||||
return TrackEntry._(entry, this);
|
||||
}
|
||||
@ -3178,16 +3137,14 @@ class AnimationState {
|
||||
/// after AnimationState.Dispose
|
||||
TrackEntry addAnimationByName(int trackIndex, String animationName, bool loop, double delay) {
|
||||
final animation = animationName.toNativeUtf8(allocator: _allocator);
|
||||
final entry = _bindings.spine_animation_state_add_animation_by_name(
|
||||
_state, trackIndex, animation.cast(), loop ? -1 : 0, delay);
|
||||
final entry = _bindings.spine_animation_state_add_animation_by_name(_state, trackIndex, animation.cast(), loop ? -1 : 0, delay);
|
||||
_allocator.free(animation);
|
||||
if (entry.address == nullptr.address) throw Exception("Couldn't add animation $animationName");
|
||||
return TrackEntry._(entry, this);
|
||||
}
|
||||
|
||||
TrackEntry addAnimation(int trackIndex, Animation animation, bool loop, double delay) {
|
||||
final entry =
|
||||
_bindings.spine_animation_state_add_animation(_state, trackIndex, animation._animation, loop ? -1 : 0, delay);
|
||||
final entry = _bindings.spine_animation_state_add_animation(_state, trackIndex, animation._animation, loop ? -1 : 0, delay);
|
||||
if (entry.address == nullptr.address) throw Exception("Couldn't add animation ${animation.getName()}");
|
||||
return TrackEntry._(entry, this);
|
||||
}
|
||||
@ -3258,7 +3215,8 @@ class SkeletonDrawable {
|
||||
_drawable = _bindings.spine_skeleton_drawable_create(skeletonData._data);
|
||||
skeleton = Skeleton._(_bindings.spine_skeleton_drawable_get_skeleton(_drawable));
|
||||
animationStateData = AnimationStateData._(_bindings.spine_skeleton_drawable_get_animation_state_data(_drawable));
|
||||
animationState = AnimationState._(_bindings.spine_skeleton_drawable_get_animation_state(_drawable), _bindings.spine_skeleton_drawable_get_animation_state_events(_drawable));
|
||||
animationState = AnimationState._(_bindings.spine_skeleton_drawable_get_animation_state(_drawable),
|
||||
_bindings.spine_skeleton_drawable_get_animation_state_events(_drawable));
|
||||
skeleton.updateWorldTransform();
|
||||
}
|
||||
|
||||
@ -3303,8 +3261,7 @@ class SkeletonDrawable {
|
||||
void renderToCanvas(Canvas canvas) {
|
||||
var commands = render();
|
||||
for (final cmd in commands) {
|
||||
canvas.drawVertices(
|
||||
cmd.vertices, rendering.BlendMode.modulate, atlas.atlasPagePaints[cmd.atlasPageIndex]);
|
||||
canvas.drawVertices(cmd.vertices, rendering.BlendMode.modulate, atlas.atlasPagePaints[cmd.atlasPageIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3335,7 +3292,10 @@ class SkeletonDrawable {
|
||||
|
||||
Future<RawImageData> renderToRawImageData(double width, double height) async {
|
||||
final recorder = renderToPictureRecorder(width, height);
|
||||
var rawImageData = (await (await recorder.endRecording().toImage(width.toInt(), height.toInt())).toByteData(format: ImageByteFormat.rawRgba))!.buffer.asUint8List();
|
||||
var rawImageData =
|
||||
(await (await recorder.endRecording().toImage(width.toInt(), height.toInt())).toByteData(format: ImageByteFormat.rawRgba))!
|
||||
.buffer
|
||||
.asUint8List();
|
||||
return RawImageData(rawImageData, width.toInt(), height.toInt());
|
||||
}
|
||||
|
||||
@ -3376,20 +3336,14 @@ class RenderCommand {
|
||||
// is copied, so it doesn't matter that we free up the underlying memory on the next
|
||||
// render call. See the implementation of Vertices.raw() here:
|
||||
// https://github.com/flutter/engine/blob/5c60785b802ad2c8b8899608d949342d5c624952/lib/ui/painting/vertices.cc#L21
|
||||
vertices = Vertices.raw(VertexMode.triangles, positions,
|
||||
textureCoordinates: uvs,
|
||||
colors: colors,
|
||||
indices: indices);
|
||||
vertices = Vertices.raw(VertexMode.triangles, positions, textureCoordinates: uvs, colors: colors, indices: indices);
|
||||
} else {
|
||||
// On the web, rendering is done through CanvasKit, which requires copies of the native data.
|
||||
final positionsCopy = Float32List.fromList(positions);
|
||||
final uvsCopy = Float32List.fromList(uvs);
|
||||
final colorsCopy = Int32List.fromList(colors);
|
||||
final indicesCopy = Uint16List.fromList(indices);
|
||||
vertices = Vertices.raw(VertexMode.triangles, positionsCopy,
|
||||
textureCoordinates: uvsCopy,
|
||||
colors: colorsCopy,
|
||||
indices: indicesCopy);
|
||||
vertices = Vertices.raw(VertexMode.triangles, positionsCopy, textureCoordinates: uvsCopy, colors: colorsCopy, indices: indicesCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,8 @@ class SpineWidgetController {
|
||||
final void Function(SpineWidgetController controller, Canvas canvas)? onBeforePaint;
|
||||
final void Function(SpineWidgetController controller, Canvas canvas, List<RenderCommand> commands)? onAfterPaint;
|
||||
|
||||
SpineWidgetController({this.onInitialized, this.onBeforeUpdateWorldTransforms, this.onAfterUpdateWorldTransforms, this.onBeforePaint, this.onAfterPaint});
|
||||
SpineWidgetController(
|
||||
{this.onInitialized, this.onBeforeUpdateWorldTransforms, this.onAfterUpdateWorldTransforms, this.onBeforePaint, this.onAfterPaint});
|
||||
|
||||
void _initialize(SkeletonDrawable drawable) {
|
||||
if (_drawable != null) throw Exception("SpineWidgetController already initialized. A controller can only be used with one widget.");
|
||||
@ -24,7 +25,7 @@ class SpineWidgetController {
|
||||
onInitialized?.call(this);
|
||||
}
|
||||
|
||||
Atlas get atlas {
|
||||
Atlas get atlas {
|
||||
if (_drawable == null) throw Exception("Controller is not initialized yet.");
|
||||
return _drawable!.atlas;
|
||||
}
|
||||
@ -46,7 +47,7 @@ class SpineWidgetController {
|
||||
|
||||
Skeleton get skeleton {
|
||||
if (_drawable == null) throw Exception("Controller is not initialized yet.");
|
||||
return _drawable!.skeleton;
|
||||
return _drawable!.skeleton;
|
||||
}
|
||||
|
||||
SkeletonDrawable get drawable {
|
||||
@ -101,8 +102,8 @@ class SkinAndAnimationBounds extends BoundsProvider {
|
||||
final String? animation;
|
||||
final double stepTime;
|
||||
|
||||
SkinAndAnimationBounds({List<String>? skins, this.animation, this.stepTime = 0.1}) :
|
||||
skins = skins == null || skins.isEmpty? ["default"] : skins;
|
||||
SkinAndAnimationBounds({List<String>? skins, this.animation, this.stepTime = 0.1})
|
||||
: skins = skins == null || skins.isEmpty ? ["default"] : skins;
|
||||
|
||||
@override
|
||||
Bounds computeBounds(SkeletonDrawable drawable) {
|
||||
@ -169,7 +170,8 @@ class SpineWidget extends StatefulWidget {
|
||||
final BoundsProvider _boundsProvider;
|
||||
final bool _sizedByBounds;
|
||||
|
||||
SpineWidget.asset(this._skeletonFile, this._atlasFile, this._controller, {AssetBundle? bundle, BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
SpineWidget.asset(this._skeletonFile, this._atlasFile, this._controller,
|
||||
{AssetBundle? bundle, BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
: _assetType = AssetType.asset,
|
||||
_fit = fit ?? BoxFit.contain,
|
||||
_alignment = alignment ?? Alignment.center,
|
||||
@ -178,7 +180,8 @@ class SpineWidget extends StatefulWidget {
|
||||
_drawable = null,
|
||||
_bundle = bundle ?? rootBundle;
|
||||
|
||||
const SpineWidget.file(this._skeletonFile, this._atlasFile, this._controller, {BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
const SpineWidget.file(this._skeletonFile, this._atlasFile, this._controller,
|
||||
{BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
: _assetType = AssetType.file,
|
||||
_bundle = null,
|
||||
_fit = fit ?? BoxFit.contain,
|
||||
@ -187,7 +190,8 @@ class SpineWidget extends StatefulWidget {
|
||||
_sizedByBounds = sizedByBounds ?? false,
|
||||
_drawable = null;
|
||||
|
||||
const SpineWidget.http(this._skeletonFile, this._atlasFile, this._controller, {BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
const SpineWidget.http(this._skeletonFile, this._atlasFile, this._controller,
|
||||
{BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
: _assetType = AssetType.http,
|
||||
_bundle = null,
|
||||
_fit = fit ?? BoxFit.contain,
|
||||
@ -196,7 +200,8 @@ class SpineWidget extends StatefulWidget {
|
||||
_sizedByBounds = sizedByBounds ?? false,
|
||||
_drawable = null;
|
||||
|
||||
const SpineWidget.drawable(this._drawable, this._controller, {BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
const SpineWidget.drawable(this._drawable, this._controller,
|
||||
{BoxFit? fit, Alignment? alignment, BoundsProvider? boundsProvider, bool? sizedByBounds, super.key})
|
||||
: _assetType = AssetType.drawable,
|
||||
_bundle = null,
|
||||
_fit = fit ?? BoxFit.contain,
|
||||
@ -250,7 +255,8 @@ class _SpineWidgetState extends State<SpineWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_drawable != null) {
|
||||
return _SpineRenderObjectWidget(_drawable!, widget._controller, widget._fit, widget._alignment, _computedBounds, widget._sizedByBounds);
|
||||
return _SpineRenderObjectWidget(
|
||||
_drawable!, widget._controller, widget._fit, widget._alignment, _computedBounds, widget._sizedByBounds);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
@ -297,6 +303,7 @@ class _SpineRenderObject extends RenderBox {
|
||||
Alignment _alignment;
|
||||
Bounds _bounds;
|
||||
bool _sizedByBounds;
|
||||
|
||||
_SpineRenderObject(this._skeletonDrawable, this._controller, this._fit, this._alignment, this._bounds, this._sizedByBounds);
|
||||
|
||||
set skeletonDrawable(SkeletonDrawable skeletonDrawable) {
|
||||
@ -389,7 +396,9 @@ class _SpineRenderObject extends RenderBox {
|
||||
}
|
||||
|
||||
Size _computeConstrainedSize(BoxConstraints constraints) {
|
||||
return sizedByParent ? constraints.smallest : constraints.constrainSizeAndAttemptToPreserveAspectRatio(Size(_bounds.width, _bounds.height));
|
||||
return sizedByParent
|
||||
? constraints.smallest
|
||||
: constraints.constrainSizeAndAttemptToPreserveAspectRatio(Size(_bounds.width, _bounds.height));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user