ConnectionBuilder constructor

ConnectionBuilder({
  1. Key? key,
  2. ConnectionBloc? bloc,
  3. @Deprecated('This builder will be removed. Use "online" instead.') WidgetBuilder? onOnline,
  4. WidgetBuilder? online,
  5. @Deprecated('This builder will be removed. Use "offline" instead.') WidgetBuilder? onOffline,
  6. WidgetBuilder? offline,
})

Implementation

ConnectionBuilder({
  super.key,
  super.bloc,
  @Deprecated('This builder will be removed. Use "online" instead.')
  WidgetBuilder? onOnline,
  WidgetBuilder? online,
  @Deprecated('This builder will be removed. Use "offline" instead.')
  WidgetBuilder? onOffline,
  WidgetBuilder? offline,
})  : assert(
        !(onOnline != null && online != null),
        'The onOnline and online builders should NOT be used together. The onOnline builder is deprecated and can be safely removed.',
      ),
      assert(
        !(onOffline != null && offline != null),
        'The onOffline and offline builders should NOT be used together. The onOffline builder is deprecated and can be safely removed.',
      ),
      super(
        builder: (BuildContext context, Connection state) {
          const none = SizedBox.shrink();
          return switch (state) {
            Connection.online =>
              (online?.call(context) ?? onOnline?.call(context)) ?? none,
            Connection.offline =>
              (offline?.call(context) ?? onOffline?.call(context)) ?? none,
          };
        },
      );