// ignore: unused_import, unnecessary_import import 'dart:io'; // Compatible with lint in Flutter 3.0.5 // ignore: unused_import, unnecessary_import import 'dart:typed_data'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'texture_rgba_renderer_platform_interface.dart'; /// An implementation of [TextureRgbaRendererPlatform] that uses method channels. class MethodChannelTextureRgbaRenderer extends TextureRgbaRendererPlatform { /// The method channel used to interact with the native platform. @visibleForTesting final methodChannel = const MethodChannel('texture_rgba_renderer'); @override Future getPlatformVersion() async { final version = await methodChannel.invokeMethod('getPlatformVersion'); return version; } @override Future createTexture(int key) async { return await methodChannel .invokeMethod('createTexture', {"key": key}) ?? -1; } @override Future closeTexture(int key) async { return await methodChannel .invokeMethod('closeTexture', {"key": key}) ?? false; } @override Future onRgba(int key, Uint8List data, int height, int width, int row_align_bytes) async { return await methodChannel.invokeMethod('onRgba', { "data": data, "height": height, "width": width, "key": key, "row_align_bytes": row_align_bytes, }) ?? false; } @override Future getTexturePtr(int key) async { final ptr = await methodChannel.invokeMethod('getTexturePtr', {"key": key}) ?? false; return ptr; } }