MessageListener constructor

MessageListener(
  1. {Key? key,
  2. required Widget child,
  3. String? errorExtractor(
    1. dynamic
    )?,
  4. String? infoExtractor(
    1. dynamic
    )?,
  5. required ProviderBase provider,
  6. required void showError(
    1. String error
    ),
  7. required void showInfo(
    1. String error
    )}
)

Implementation

factory MessageListener({
  Key? key,
  required Widget child,
  String? Function(dynamic)? errorExtractor,
  String? Function(dynamic)? infoExtractor,
  required ProviderBase provider,
  required void Function(String error) showError,
  required void Function(String error) showInfo,
}) {
  if (provider is StateNotifierProvider) {
    return MessageListener._stateNotifier(
        provider: provider,
        showError: showError,
        showInfo: showInfo,
        errorExtractor: errorExtractor,
        infoExtractor: infoExtractor,
        child: child);
  } else if (provider is AutoDisposeStateNotifierProvider) {
    return MessageListener._autoDisposeStateNotifier(
        provider: provider,
        showError: showError,
        showInfo: showInfo,
        errorExtractor: errorExtractor,
        infoExtractor: infoExtractor,
        child: child);
  } else if (provider is ChangeNotifierProvider) {
    return MessageListener._changeNotifier(
        provider: provider,
        showError: showError,
        showInfo: showInfo,
        errorExtractor: errorExtractor,
        infoExtractor: infoExtractor,
        child: child);
  } else if (provider is AutoDisposeChangeNotifierProvider) {
    return MessageListener._autoDisposeChangeNotifier(
        provider: provider,
        showError: showError,
        showInfo: showInfo,
        errorExtractor: errorExtractor,
        infoExtractor: infoExtractor,
        child: child);
  } else {
    throw UnimplementedError(
        'riverpod_messages supports only StateNotifier or ChangeNotifier');
  }
}