mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 18:29:39 +00:00
use switch state instead of if else
This commit is contained in:
@ -1,5 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart';
|
import 'package:syncrow_web/pages/access_management/manage_bookable_spaces/domain/params/non_bookable_spaces_params.dart';
|
||||||
@ -123,14 +121,12 @@ class _SpacesStepDetailsWidgetState extends State<SpacesStepDetailsWidget> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is NonBookableSpacesError) {
|
return switch (state) {
|
||||||
return Column(
|
NonBookableSpacesError(error: final error) => Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(state.error),
|
Text(error),
|
||||||
const SizedBox(
|
const SizedBox(height: 5),
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<NonBookableSpacesBloc>().add(
|
context.read<NonBookableSpacesBloc>().add(
|
||||||
@ -143,28 +139,28 @@ class _SpacesStepDetailsWidgetState extends State<SpacesStepDetailsWidget> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Try Again'))
|
child: const Text('Try Again'),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
),
|
||||||
} else if (state is NonBookableSpacesLoading) {
|
NonBookableSpacesLoading(lastNonBookableSpaces: null) =>
|
||||||
if (state.lastNonBookableSpaces == null) {
|
const Center(child: CircularProgressIndicator()),
|
||||||
return const Center(
|
NonBookableSpacesLoading(
|
||||||
child: CircularProgressIndicator(),
|
lastNonBookableSpaces: final spaces
|
||||||
);
|
) =>
|
||||||
} else {
|
UnbookableListWidget(
|
||||||
return UnbookableListWidget(
|
|
||||||
scrollController: scrollController,
|
scrollController: scrollController,
|
||||||
nonBookableSpaces: state.lastNonBookableSpaces!,
|
nonBookableSpaces: spaces!,
|
||||||
);
|
),
|
||||||
}
|
NonBookableSpacesLoaded(
|
||||||
} else if (state is NonBookableSpacesLoaded) {
|
nonBookableSpaces: final spaces
|
||||||
return UnbookableListWidget(
|
) =>
|
||||||
|
UnbookableListWidget(
|
||||||
scrollController: scrollController,
|
scrollController: scrollController,
|
||||||
nonBookableSpaces: state.nonBookableSpaces,
|
nonBookableSpaces: spaces,
|
||||||
);
|
),
|
||||||
} else {
|
_ => const SizedBox(),
|
||||||
return const SizedBox();
|
};
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user