颤振中两个或多个点之间的垂直虚线

问题描述 投票:1回答:2

我需要一点帮助来在2点之间绘制虚线,而无需使用Google地图的折线。我尝试使用画布,但它确实不能完全在位置下方和上方开始。

现在,您可以看到2点,它将超过2点。如果有人帮助我实现目标,我将不胜感激。

Expected Result

flutter path flutter-layout dotted-line
2个回答
0
投票

我使用https://pub.dev/packages/flutter_dash制作了几乎相同外观的小部件,您也可以根据自己的风格自定义此小部件。

enter image description here

这里是代码,希望有帮助。

  Column(children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(top: 16),
                    height: 25,
                    width: 25,
                    decoration: BoxDecoration(
                        shape: BoxShape.circle,
                        border:
                            Border.all(width: 1.5, color: Colors.greenAccent)),
                  ),
                  Dash(
                      direction: Axis.vertical,
                      length: 130,
                      dashLength: 15,
                      dashColor: grey),
                  Container(
                    height: 25,
                    width: 25,
                    decoration: BoxDecoration(
                        shape: BoxShape.rectangle,
                        border: Border.all(width: 2, color: red)),
                    child: Container(
                      height: 20,
                    ),
                  ),
                ],
              ),

0
投票
return Container(
    child: Row(
    children: <Widget>[
      Column(children: <Widget>[
              Icon(Icons.radio_button_checked,color: Colors.orange,)
              Dash(
                  direction: Axis.vertical,
                  length: 20,
                  dashLength: 5,
                  thickness:3.0,
                  dashColor: Colors.grey[400]),
              Icon(Icons.location_on,color: Colors.blue,)
            ],
          ),
      Column(children: <Widget>[
              Text("Some text"),
              Divider(),
              Text("Some Text")
            ],
          ),
    ],

    )
);

0
投票
class _MyWidgetState extends State<MyWidget> {
  List<Model> list = [];

  @override
  void initState() {
    super.initState();
    list.add(Model("Hyderabad", Colors.red));
    list.add(Model("Visakhapatnam", Colors.green));
    list.add(Model("Vijayawada", Colors.blue));
  }

  void addNew() {
    setState(() {
      list.add(Model("Karnool", Colors.black));
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
            backgroundColor: Colors.black,
            title:
                Text('Custom Stepper', style: TextStyle(color: Colors.white)),
            actions: [
              IconButton(
                  icon: Icon(Icons.add_circle, color: Colors.white),
                  onPressed: addNew)
            ]),
        body: Container(
            padding: EdgeInsets.all(15),
            color: Colors.white,
            child: ListView.builder(
                itemCount: list.length,
                itemBuilder: (con, ind) {
                  return ind != 0
                      ? Column(mainAxisSize: MainAxisSize.min, children: [
                          Row(children: [
                            Column(
                              children: List.generate(
                                3,
                                (ii) => Padding(
                                    padding: EdgeInsets.only(
                                        left: 10, right: 10, top: 5, bottom: 5),
                                    child: Container(
                                      height: 3,
                                      width: 2,
                                      color: Colors.grey,
                                    )),
                              ),
                            ),
                            Expanded(
                                child: Container(
                              color: Colors.grey.withAlpha(60),
                              height: 0.5,
                              padding: EdgeInsets.only(
                                left: 10,
                                right: 20,
                              ),
                            ))
                          ]),
                          Row(children: [
                            Icon(Icons.location_on, color: list[ind].color),
                            Text(list[ind].address,
                                style: TextStyle(color: list[ind].color))
                          ])
                        ])
                      : Row(children: [
                          Icon(Icons.location_on, color: list[ind].color),
                          Text(list[ind].address,
                              style: TextStyle(color: list[ind].color))
                        ]);
                })));
  }
}

class Model {
  String address;
  double lat;
  double long;
  Color color;
  //Other fields if needed....
  Model(this.address, this.color);
  //initialise other fields so on....
}

Screenshot

© www.soinside.com 2019 - 2024. All rights reserved.