refactor(bloc_helper): docs + nullable multiprovider attributes
This commit is contained in:
@@ -77,9 +77,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
class MultiProvider extends StatelessWidget {
|
||||
/// {@macro multi_provider}
|
||||
const MultiProvider({
|
||||
required this.repositoryProviders,
|
||||
required this.blocProviders,
|
||||
required this.child,
|
||||
this.repositoryProviders = const <RepositoryProvider<dynamic>>[],
|
||||
this.blocProviders = const <BlocProvider>[],
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -88,11 +88,31 @@ class MultiProvider extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => MultiRepositoryProvider(
|
||||
providers: repositoryProviders,
|
||||
child: MultiBlocProvider(
|
||||
providers: blocProviders,
|
||||
child: child,
|
||||
),
|
||||
Widget build(BuildContext context) {
|
||||
if (repositoryProviders.isEmpty && blocProviders.isEmpty) {
|
||||
return child;
|
||||
}
|
||||
|
||||
if (repositoryProviders.isEmpty) {
|
||||
return MultiBlocProvider(
|
||||
providers: blocProviders,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
if (blocProviders.isEmpty) {
|
||||
return MultiRepositoryProvider(
|
||||
providers: repositoryProviders,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
return MultiRepositoryProvider(
|
||||
providers: repositoryProviders,
|
||||
child: MultiBlocProvider(
|
||||
providers: blocProviders,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user