blob: a3a5ab43350eac09e01faccb1d53788fb92f9ebe [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
/// A serialization of a platform image's data.
class PlatformImageData {
PlatformImageData({
required this.data,
required this.scale,
});
/// The image data.
Uint8List data;
/// The image's scale factor.
double scale;
Object encode() {
return <Object?>[
data,
scale,
];
}
static PlatformImageData decode(Object result) {
result as List<Object?>;
return PlatformImageData(
data: result[0]! as Uint8List,
scale: result[1]! as double,
);
}
}
class _PlatformImagesApiCodec extends StandardMessageCodec {
const _PlatformImagesApiCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is PlatformImageData) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return PlatformImageData.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
}
}
class PlatformImagesApi {
/// Constructor for [PlatformImagesApi]. The [binaryMessenger] named argument is
/// available for dependency injection. If it is left null, the default
/// BinaryMessenger will be used which routes to the host platform.
PlatformImagesApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = _PlatformImagesApiCodec();
/// Returns the URL for the given resource, or null if no such resource is
/// found.
Future<String?> resolveUrl(
String arg_resourceName, String? arg_extension) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.resolveUrl',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel
.send(<Object?>[arg_resourceName, arg_extension]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return (replyList[0] as String?);
}
}
/// Returns the data for the image resource with the given name, or null if
/// no such resource is found.
Future<PlatformImageData?> loadImage(String arg_name) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.loadImage',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_name]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return (replyList[0] as PlatformImageData?);
}
}
}