crop_image_handler.dart 710 Bytes
import 'package:appframe/services/dispatcher.dart';

class CropImageHandler extends MessageHandler {
  @override
  Future<dynamic> handleMessage(params) async {
    if (params is! Map<String, dynamic>) {
      throw Exception('参数错误');
    }
    var url = params['sourceType'] as String?;
    if (url == null || url.isEmpty) {
      throw Exception('参数错误');
    }
    var cropScale = params['scale'] as String?;
    if (cropScale == null || cropScale.isEmpty) {
      throw Exception('参数错误');
    }
    var scaleArray = ['16:9', '9:16', '4:3', '3:4', '5:4', '4:5', '1:1'];
    if (!scaleArray.contains(cropScale)) {
      throw Exception('参数错误');
    }

    return false;

  }
}