Search code examples
fluttercontainersrowtextfield

Flutter: How to not change textfield postion when increasing height of container in row


I am trying to create this, but when i increase the height of container by textfield changes it position to top.

enter image description here

here is my code:


 Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        children: [
          Expanded(
            child: CustomTextfield(
              isPrefixIcon: false,
              bgColor: AppColors.whiteColor,
              borderColor: AppColors.blueColor,
              hintColor: AppColors.blackColor,
              isBorder: true,
              hintText: AppStrings.typeMessage,
              suffixIcon: Image.asset(AssetPaths.sendIcon,scale: 1.5,),
            ),
          ),
          sizedboxWidth5(),
          Container(
            height: 120.h,width: 40.w,
            decoration: BoxDecoration(color: AppColors.blueColor,borderRadius: BorderRadius.circular(30)),)
          
        ]
      ),
    );

here is my code output

enter image description here


Solution

  • In Row widget theres a properties mainAxisAlignment and crossAxisAlignment

    mainAxisAlignment in Row widget means the horizontally

    crossAxisAlignment in Row widget means the vertically.

    On your issue, try to change the crossAxisAlignment value. Check the code below:

    Row(
      crossAxisAlignment: CrossAxisAlignment.end, /// add this
      children: [
       /// ....
      ],
    ),