create method

  1. @override
Future<bool> create({
  1. required String coverImage,
  2. String? imagePath,
  3. String? voicePath,
  4. required int width,
  5. required int height,
})
override

Implementation

@override
Future<bool> create({
  required String coverImage,
  String? imagePath,
  String? voicePath,
  required int width,
  required int height,
}) async {
  assert(Platform.isIOS, 'Live photo can only be used on the iOS platform.');

  assert(
      ((imagePath ?? '').isNotEmpty && (voicePath ?? '').isEmpty) ||
          ((imagePath ?? '').isEmpty && (voicePath ?? '').isNotEmpty),
      "Either imagePath or voicePath should have a value, and both cannot be empty.");

  late String movPath;
  if ((voicePath ?? '').isNotEmpty) {
    movPath = voicePath!;
  } else {
    movPath = await methodChannel.invokeMethod("image_to_mov", [imagePath, width.toString(), height.toString()]);
  }

  String result = await methodChannel.invokeMethod("create_live_photo", [coverImage, movPath]);
  if (result == 'success') {
    return true;
  } else {
    return false;
  }
}