forked from eatvio/eatvio_app
refactor(diary): Refactoring flutter analyze finished. Started refactoring Run Code Metrics
This commit is contained in:
@@ -64,23 +64,22 @@ class LanguageSelectScreen extends StatelessWidget {
|
||||
languageSelectModelObj,
|
||||
) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin:
|
||||
EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize)),
|
||||
hintText: "Не выбрано".tr,
|
||||
items:
|
||||
languageSelectModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<LanguageSelectBloc>()
|
||||
.add(ChangeDropDownEvent(value: value));
|
||||
});
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(1.h),
|
||||
),
|
||||
child: CustomImageView(
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize,
|
||||
),
|
||||
),
|
||||
hintText: "Не выбрано".tr,
|
||||
items: languageSelectModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) =>
|
||||
_onDropDownChanged(context, value),
|
||||
);
|
||||
}),
|
||||
Spacer(flex: 63),
|
||||
])),
|
||||
@@ -92,15 +91,24 @@ class LanguageSelectScreen extends StatelessWidget {
|
||||
margin:
|
||||
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.languageSelectModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.credentialsScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
});
|
||||
onPressed: _saveAndPush(state, context));
|
||||
})));
|
||||
}
|
||||
|
||||
void Function()? _saveAndPush(
|
||||
LanguageSelectState state, BuildContext context) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.languageSelectModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.credentialsScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
void _onDropDownChanged(BuildContext context, value) {
|
||||
context.read<LanguageSelectBloc>().add(ChangeDropDownEvent(value: value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ class AppbarLeadingImage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
onTap!.call();
|
||||
},
|
||||
onTap: onTapCall,
|
||||
child: Padding(
|
||||
padding: margin ?? EdgeInsets.zero,
|
||||
child: CustomImageView(
|
||||
@@ -35,4 +33,8 @@ class AppbarLeadingImage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTapCall() {
|
||||
onTap!.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ class AppbarSubtitle extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onTap!.call();
|
||||
},
|
||||
onTap: onTapCall,
|
||||
child: Padding(
|
||||
padding: margin ?? EdgeInsets.zero,
|
||||
child: Text(
|
||||
@@ -35,4 +33,8 @@ class AppbarSubtitle extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTapCall() {
|
||||
onTap!.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,7 @@ class AppbarTitleCircleimage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () {
|
||||
onTap!.call();
|
||||
},
|
||||
onTap: onTapCall,
|
||||
child: Padding(
|
||||
padding: margin ?? EdgeInsets.zero,
|
||||
child: CustomImageView(
|
||||
@@ -39,4 +37,8 @@ class AppbarTitleCircleimage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTapCall() {
|
||||
onTap!.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ class AppbarTitleImage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
onTap!.call();
|
||||
},
|
||||
onTap: onTapCall,
|
||||
child: Padding(
|
||||
padding: margin ?? EdgeInsets.zero,
|
||||
child: CustomImageView(
|
||||
@@ -35,4 +33,8 @@ class AppbarTitleImage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTapCall() {
|
||||
onTap!.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ class ExitButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onTap!.call();
|
||||
},
|
||||
onTap: onTapCall,
|
||||
child: Padding(
|
||||
padding: margin ?? EdgeInsets.zero,
|
||||
child: Text(
|
||||
@@ -35,4 +33,8 @@ class ExitButton extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTapCall() {
|
||||
onTap!.call();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,60 +65,63 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
elevation: 0,
|
||||
currentIndex: selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: List.generate(bottomMenuList.length, (index) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].icon,
|
||||
height: 24.v,
|
||||
width: 19.h,
|
||||
color: appTheme.blueGray400,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title ?? "",
|
||||
style:
|
||||
CustomTextStyles.bodySmallMulishBluegray80012.copyWith(
|
||||
color: appTheme.blueGray800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
activeIcon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].activeIcon,
|
||||
height: 24.adaptSize,
|
||||
width: 24.adaptSize,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 9.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title ?? "",
|
||||
style: CustomTextStyles.bodySmallMulishPrimary.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
label: '',
|
||||
);
|
||||
}),
|
||||
onTap: (index) {
|
||||
selectedIndex = index;
|
||||
widget.onChanged?.call(bottomMenuList[index].type);
|
||||
setState(() {});
|
||||
},
|
||||
items: List.generate(bottomMenuList.length, bottomMenu),
|
||||
onTap: changeMeny,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void changeMeny(index) {
|
||||
selectedIndex = index;
|
||||
widget.onChanged?.call(bottomMenuList[index].type);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
BottomNavigationBarItem bottomMenu(index) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].icon,
|
||||
height: 24.v,
|
||||
width: 19.h,
|
||||
color: appTheme.blueGray400,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title ?? "",
|
||||
style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith(
|
||||
color: appTheme.blueGray800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
activeIcon: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: bottomMenuList[index].activeIcon,
|
||||
height: 24.adaptSize,
|
||||
width: 24.adaptSize,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 9.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title ?? "",
|
||||
style: CustomTextStyles.bodySmallMulishPrimary.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
label: '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum BottomBarEnum {
|
||||
@@ -141,27 +144,3 @@ class BottomMenuModel {
|
||||
|
||||
BottomBarEnum type;
|
||||
}
|
||||
|
||||
class DefaultWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Center(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Please replace the respective Widget here',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,67 +81,79 @@ class CustomTextFormField extends StatelessWidget {
|
||||
|
||||
final void Function(String?)? onSaved;
|
||||
|
||||
To resolve the error "Avoid returning widgets from a getter," you can refactor the textFormFieldWidget and decoration getters into regular methods and then call those methods within the build method. Here's the refactored code:
|
||||
|
||||
dart
|
||||
|
||||
class CustomTextFormField extends StatelessWidget {
|
||||
// ... other properties remain the same
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return alignment != null
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: textFormFieldWidget,
|
||||
child: _buildTextFormFieldWidget(),
|
||||
)
|
||||
: textFormFieldWidget;
|
||||
: _buildTextFormFieldWidget();
|
||||
}
|
||||
|
||||
Widget get textFormFieldWidget => SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
decoration: decoration,
|
||||
validator: validator,
|
||||
keyboardType: keyboardType,
|
||||
onSaved: onSaved,
|
||||
inputFormatters: inputFormatters,
|
||||
),
|
||||
);
|
||||
InputDecoration get decoration => InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
||||
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
Widget _buildTextFormFieldWidget() {
|
||||
return SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
decoration: _buildInputDecoration(),
|
||||
validator: validator,
|
||||
keyboardType: keyboardType,
|
||||
onSaved: onSaved,
|
||||
inputFormatters: inputFormatters,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
InputDecoration _buildInputDecoration() {
|
||||
return InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
||||
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -31,43 +31,59 @@ class NextStepButton extends BaseButton {
|
||||
);
|
||||
|
||||
final BoxDecoration? decoration;
|
||||
|
||||
final Widget? leftIcon;
|
||||
|
||||
final Widget? rightIcon;
|
||||
|
||||
final Widget? label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return alignment != null
|
||||
return (alignment != null)
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: buildOutlinedButtonWidget,
|
||||
)
|
||||
: buildOutlinedButtonWidget;
|
||||
}
|
||||
|
||||
Widget get buildOutlinedButtonWidget => Container(
|
||||
height: this.height ?? 30.v,
|
||||
width: this.width ?? double.maxFinite,
|
||||
margin: margin,
|
||||
decoration: decoration,
|
||||
child: OutlinedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: isDisabled ?? false ? null : onPressed ?? () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
leftIcon ?? const SizedBox.shrink(),
|
||||
Text(
|
||||
text,
|
||||
style: buttonTextStyle ?? theme.textTheme.titleSmall,
|
||||
alignment: alignment!,
|
||||
child: Container(
|
||||
height: this.height ?? 30.v,
|
||||
width: this.width ?? double.maxFinite,
|
||||
margin: margin,
|
||||
decoration: decoration,
|
||||
child: OutlinedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: isDisabled ?? false ? null : onPressed ?? () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
leftIcon ?? const SizedBox.shrink(),
|
||||
Text(
|
||||
text,
|
||||
style: buttonTextStyle ?? theme.textTheme.titleSmall,
|
||||
),
|
||||
rightIcon ?? const SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
rightIcon ?? const SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: this.height ?? 30.v,
|
||||
width: this.width ?? double.maxFinite,
|
||||
margin: margin,
|
||||
decoration: decoration,
|
||||
child: OutlinedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: isDisabled ?? false ? null : onPressed ?? () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
leftIcon ?? const SizedBox.shrink(),
|
||||
Text(
|
||||
text,
|
||||
style: buttonTextStyle ?? theme.textTheme.titleSmall,
|
||||
),
|
||||
rightIcon ?? const SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user