$scene<Data, Loading, Error> function
BaseBLoCWidget
$scene<Data, Loading, Error>(
- LiveScene<
Data, Loading, Error> state, { - Key? key,
- required Widget child(
- BuildContext context,
- Data data
- required Widget onEmptyData(
- BuildContext context
- required Widget onLoading(
- BuildContext context,
- Loading loading
- required Widget onError(
- BuildContext context,
- Error error
Implementation
BaseBLoCWidget $scene<Data, Loading, Error>(
LiveScene<Data, Loading, Error> state, {
Key? key,
required Widget Function(BuildContext context, Data data) child,
required Widget Function(BuildContext context) onEmptyData,
required Widget Function(BuildContext context, Loading loading) onLoading,
required Widget Function(BuildContext context, Error error) onError,
}) {
// return BaseBLoCWidget(key: key);
return $guard.isNotNull(
state.error,
build: (context, Error? error) {
return BLoCWidget(
child: (context, {key}) {
return onError(context, error!);
},
);
},
) |
$guard(
state.loading,
when: (data) => data != null || (data is bool && data),
build: (context, Loading? loading) {
return BLoCWidget(
child: (context, {key}) {
return onLoading(context, loading!);
},
);
},
) |
$guard(
state.data,
when: (data) => data == null || (data is List && data.isEmpty),
build: (context, Data? data) {
return BLoCWidget(
child: (context, {key}) {
return onEmptyData(context);
},
);
},
) |
$watch(
state.data,
build: (context, Data? data) {
return child(context, data!);
},
);
}