selfprivacy.org.app/lib/config/bloc_config.dart
kherel 3e7d003f21 service-states (#65)
Co-authored-by: Kherel <kherel@gmail.com>
Reviewed-on: https://git.selfprivacy.org/kherel/selfprivacy.org.app/pulls/65
Co-authored-by: kherel <kherel@gmail.com>
Co-committed-by: kherel <kherel@gmail.com>
2021-09-29 16:08:19 +03:00

42 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
import 'package:selfprivacy/logic/cubit/users/users_cubit.dart';
class BlocAndProviderConfig extends StatelessWidget {
const BlocAndProviderConfig({Key? key, this.child}) : super(key: key);
final Widget? child;
@override
Widget build(BuildContext context) {
var isDark = false;
var usersCubit = UsersCubit();
var appConfigCubit = AppConfigCubit()..load();
var servicesCubit = ServicesCubit(appConfigCubit);
return MultiProvider(
providers: [
BlocProvider(
create: (_) => AppSettingsCubit(
isDarkModeOn: isDark,
isOnbordingShowing: true,
)..load(),
),
BlocProvider(lazy: false, create: (_) => appConfigCubit),
BlocProvider(create: (_) => ProvidersCubit()),
BlocProvider(create: (_) => usersCubit..load(), lazy: false),
BlocProvider(create: (_) => servicesCubit..load(), lazy: false),
BlocProvider(
create: (_) =>
JobsCubit(usersCubit: usersCubit, servicesCubit: servicesCubit),
),
],
child: child,
);
}
}