How to give a “Dashed Border” in flutter?

前端 未结 5 1986
名媛妹妹
名媛妹妹 2021-01-01 18:00

I try to give dashed border in flutter but there is no option for dashed border in flutter. so any another way to create dashed border in futter.

  new Conta         


        
5条回答
  •  死守一世寂寞
    2021-01-01 18:53

    You can use dashPattern, an attribute which allows you to specify the Dash Sequence by passing in an Array of Doubles.

    DottedBorder(
        dashPattern: [6, 3, 2, 3], 
        child: ...
    );
    

    This code gives a dashed sequence of width 6, space 3, width 2, space 3,.... and this continues.

    To get a Dashed line across the screen, use

    DottedBorder(
      color: Color(0xFFE9EBF5),
      strokeWidth: 1,
      radius: Radius.circular(10),
      dashPattern: [5, 5],
      customPath: (size) {
        return Path()
          ..moveTo(0, 10)
          ..lineTo(size.width, 10);
      },
      child: Container(),
    ),
    

提交回复
热议问题