call method

dynamic call(
  1. String methodName,
  2. List data
)

Implementation

call(String methodName, List<dynamic> data) {
  switch (methodName) {
    case 'onContent':
      onContent((data[0] as String?) ?? '');
      return false; // 非终态,保留监听
    case 'onSuggestions':
      onSuggestions((data[0] as List?)?.map((e) => e.toString()).toList() ?? const []);
      return false; // 非终态
    case 'onDone':
      onDone();
      return true; // 终态
    case 'onError':
      onError(data.isNotEmpty ? data[0] as String? : null, data.length > 1 ? data[1] as String? : null);
      return true; // 终态
  }
  return false;
}