Flutter - Vertical Divider - How to add Vertical Divider?

Some times we may required to add vertical line inside our UI, How do we add vertical divider inside other widget.

By using VerticalDivider widget we can add vertical divider in between widgets.

VerticalDivider(),

 

Constructor

VerticalDivider({
  Key? key,
  this.width,
  this.thickness,
  this.indent,
  this.endIndent,
  this.color,
}) 

 

Properties:

color: Set the divider color
thickness: Set the Thikness for the divider
indent: set the Space at the top of the divider
endIndent: Set the space at the bottom of the divider

 

When we add verticaldivider inside row widget it will not show. We can overcome not showing verticaldivider issue by

  • Add Your Row widget inside IntrinsicHeight widget
  • Add VerticalDivider inside SizedBox widget with required height

 

Flutter Vertical divider

 

Example with IntrinsicHeight

IntrinsicHeight(
  child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
    Icon(Icons.menu,color: AppColors.technoBlack,),
    SizedBox(width: 5.w,),
    Expanded(child: TextField(
    style: TextStyle(fontSize: 16.sp,color: AppColors.technoBlack,fontWeight: FontWeight.w300),
      decoration: InputDecoration(
      hintText: "Your Current Location",
      focusedBorder: InputBorder.none,


    ),)),
      SizedBox(width: 5.w,),

    VerticalDivider(color: AppColors.technoBlack,thickness: 2),
      SizedBox(width: 5.w,),
    Icon(Icons.filter_tilt_shift,color: AppColors.technoBlack,),
  ],),
),

 

Example with VerticalDivider

Row(
  
  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  crossAxisAlignment: CrossAxisAlignment.center,
  children: [
  Icon(Icons.menu,color: AppColors.technoBlack,),
  SizedBox(width: 5.w,),
  Expanded(child: TextField(
  style: TextStyle(fontSize: 16.sp,color: AppColors.technoBlack,fontWeight: FontWeight.w300),
    decoration: InputDecoration(
    hintText: "Your Current Location",
    focusedBorder: InputBorder.none,


  ),)),
    SizedBox(width: 5.w,),

  SizedBox(child: VerticalDivider(color: AppColors.technoBlack,thickness: 2,),height: 30,),
    SizedBox(width: 5.w,),
  Icon(Icons.filter_tilt_shift,color: AppColors.technoBlack,),
],),