Migrate constraint check to utils

This commit is contained in:
Ankit Mahato
2023-07-20 01:33:03 +05:30
parent f5ac9f827e
commit bf49a56c0f
3 changed files with 17 additions and 12 deletions

View File

@ -2,3 +2,4 @@ export 'ui_utils.dart';
export 'convert_utils.dart';
export 'http_utils.dart';
export 'file_utils.dart';
export 'window_utils.dart';

View File

@ -0,0 +1,12 @@
bool showButtonLabelsInBodySuccess(int options, double maxWidth) {
switch (options) {
case 1:
return (maxWidth < 300) ? false : true;
case 2:
return (maxWidth < 400) ? false : true;
case 3:
return (maxWidth < 500) ? false : true;
default:
return false;
}
}

View File

@ -400,18 +400,10 @@ class _BodySuccessState extends State<BodySuccess> {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
var showLabel = false;
switch (widget.options.length) {
case 1:
showLabel = (constraints.maxWidth < 300) ? false : true;
break;
case 2:
showLabel = (constraints.maxWidth < 400) ? false : true;
break;
case 3:
showLabel = (constraints.maxWidth < 500) ? false : true;
break;
}
var showLabel = showButtonLabelsInBodySuccess(
widget.options.length,
constraints.maxWidth,
);
return Padding(
padding: kP10,
child: Column(