feat(bloc_layout): rework on structure using new components and layouts
This commit is contained in:
@@ -62,13 +62,13 @@ class MyApp extends StatelessWidget {
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (_) => ExampleCubit()..run(),
|
||||
child: const ExampleFrameLayoutCrudConsumer(),
|
||||
child: ExampleFrameLayoutCrudConsumer(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (_) => ExampleCubit()..runList(),
|
||||
child: const ExampleFrameLayoutCrudListConsumer(),
|
||||
child: ExampleFrameLayoutCrudListConsumer(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -82,7 +82,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ExampleCrudStateManagement
|
||||
extends CrudCubitConsumerScreen<ExampleCubit, String> {
|
||||
extends CubitScreenCrudItemBase<ExampleCubit, String> {
|
||||
const ExampleCrudStateManagement({super.key});
|
||||
|
||||
@override
|
||||
@@ -91,10 +91,13 @@ class ExampleCrudStateManagement
|
||||
@override
|
||||
Widget successBuilder(BuildContext context, CrudLoaded<String> state) =>
|
||||
Center(child: Text(state.data ?? 'errors'));
|
||||
|
||||
@override
|
||||
ExampleCubit create(BuildContext context) => ExampleCubit()..run();
|
||||
}
|
||||
|
||||
class ExampleListCrudStateManagement
|
||||
extends CrudListCubitConsumerScreen<ExampleCubit, String> {
|
||||
extends CubitScreenCrudListBase<ExampleCubit, String> {
|
||||
const ExampleListCrudStateManagement({super.key});
|
||||
|
||||
@override
|
||||
@@ -106,27 +109,35 @@ class ExampleListCrudStateManagement
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: state.data.map((e) => Text(e ?? 'error')).toList(),
|
||||
);
|
||||
|
||||
@override
|
||||
ExampleCubit create(BuildContext context) => ExampleCubit()..run();
|
||||
}
|
||||
|
||||
class ExampleFrameLayoutCrudConsumer
|
||||
extends FrameLayoutCrudCubitConsumerScreen<ExampleCubit, String> {
|
||||
const ExampleFrameLayoutCrudConsumer({super.key})
|
||||
extends FrameLayoutCubitScreenCrudItem<ExampleCubit, String> {
|
||||
ExampleFrameLayoutCrudConsumer({super.key})
|
||||
: super(
|
||||
title: 'Example Title',
|
||||
currentIndex: 0,
|
||||
customAppBar: (bar) => bar?.copyWith.title(
|
||||
'Example Title'.wrap(),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget successBuilder(BuildContext context, CrudLoaded<String> state) =>
|
||||
Center(child: Text(state.data ?? 'errors'));
|
||||
|
||||
@override
|
||||
ExampleCubit create(BuildContext context) => ExampleCubit()..run();
|
||||
}
|
||||
|
||||
class ExampleFrameLayoutCrudListConsumer
|
||||
extends FrameLayoutCrudListCubitConsumerScreen<ExampleCubit, String> {
|
||||
const ExampleFrameLayoutCrudListConsumer({super.key})
|
||||
extends FrameLayoutCubitScreenCrudList<ExampleCubit, String> {
|
||||
ExampleFrameLayoutCrudListConsumer({super.key})
|
||||
: super(
|
||||
title: 'Example Title',
|
||||
currentIndex: 0,
|
||||
customAppBar: (bar) => bar?.copyWith.title(
|
||||
'Example Title'.wrap(),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -135,4 +146,7 @@ class ExampleFrameLayoutCrudListConsumer
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: state.data.map((e) => Text(e ?? 'error')).toList(),
|
||||
);
|
||||
|
||||
@override
|
||||
ExampleCubit create(BuildContext context) => ExampleCubit()..run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user