ConfigurableErrorLocalizer class

可配置本地化器(支持部分覆盖)

提供三层回退机制:

  1. 开发者覆盖(overrides)
  2. 自定义 Localizer(fallback)
  3. 默认中文(DefaultErrorLocalizer)

示例:

// 部分覆盖
final localizer = ConfigurableErrorLocalizer(
  overrides: {
    ErrorKey.network: (_, __) => 'Please check your network',
    ErrorKey.response: template('Server error: {statusCode}'),
    ErrorKey.timeout(TimeoutPhase.connect): (_, __) => 'Connection timed out',
  },
);

// 与 Flutter intl 集成
final localizer = ConfigurableErrorLocalizer(
  fallback: IntlErrorLocalizer(context),
  overrides: { /* 特殊覆盖 */ },
);
Implemented types

Constructors

ConfigurableErrorLocalizer({SmartErrorLocalizer? fallback, Map<ErrorKey, MessageTemplate>? overrides})
创建可配置本地化器

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

localize(SmartError error) String
SmartError 转换为用户友好的本地化消息
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited