【问题标题】:How to create custom stepper in flutter?如何在颤振中创建自定义步进器?
【发布时间】:2021-02-13 01:51:29
【问题描述】:

我想在 Flutter 中创建这种类型的步进器

到目前为止我已经尝试了这两种方法

Widget get stepper =>
      Container(
          padding: EdgeInsets.all(15),
          color: Colors.white,
          child: ListView.builder(
              itemCount: stepperLIst.length,
              shrinkWrap: true,
              physics: NeverScrollableScrollPhysics(),
              itemBuilder: (context, position) {
                return IntrinsicHeight(
                  child: Container(
                    margin: const EdgeInsets.only(bottom: 20),
                    child: Row(
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Column(
                            mainAxisSize: MainAxisSize.min,
                            verticalDirection: VerticalDirection.down,
                            children: [
                              Image.asset(stepperLIst[position].iconName),
                              SizedBox(height: 10),
                              CustomPaint(painter: LineDashedPainter(lineColor: Colors.grey))

                            ],
                          ),
                          SizedBox(width: 10),
                          Expanded(
                            child: Column(
                              mainAxisSize: MainAxisSize.min,
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  stepperLIst[position].tittle,
                                  style: BaseStyles.textStyle.copyWith(fontFamily: BaseFonts.bold),
                                ),
                                SizedBox(height: 10),
                                Text(
                                  stepperLIst[position].value,
                                  style: BaseStyles.textStyle,
                                )
                              ],
                            ),
                          )
                        ]),
                  ),
                );
              }));

也使用堆栈

  Widget get stepper2 =>
  Container(
      padding: EdgeInsets.all(15),
      color: Colors.white,
      child: ListView.builder(
          itemCount: stepperLIst.length,
          shrinkWrap: true,
          physics: NeverScrollableScrollPhysics(),
          itemBuilder: (context, position) {
            return Stack(
              children: <Widget>[
                Positioned(
                  left: 0,
                  top: 0,
                  bottom: 0,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    verticalDirection: VerticalDirection.down,
                    children: [
                      Image.asset(stepperLIst[position].iconName),
                      SizedBox(height: 10),
                      CustomPaint(painter: LineDashedPainter(lineColor: Colors.grey))

                    ],
                  ), // replace with your image
                ),
                Padding(
                  padding: const EdgeInsets.only(left: 40),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        stepperLIst[position].tittle,
                        style: BaseStyles.textStyle.copyWith(fontFamily: BaseFonts.bold),
                      ),
                      SizedBox(height: 10),
                      Text(
                        stepperLIst[position].value,
                        style: BaseStyles.textStyle,
                      )
                    ],
                  ),
                )
              ],
            );
          }));

使用上面的代码我没有得到准确的输出

谁能帮我制作这种类型的步进器

如果需要更多信息,请告诉我。提前致谢。您的努力将不胜感激。

【问题讨论】:

    标签: android ios flutter dart flutter-layout


    【解决方案1】:

    我有一些资源要与您分享。只需检查一下,看看是否适合您。它们是:

    如果您真的希望这些交错线代替 Stepper 中的图标之间的单个垂直线,请查看库的代码并制作您自己的小部件,只需进行一些最小的更改。

    【讨论】:

    • 感谢您的努力和建议,我尝试使用步进小部件,但我的要求是显示所有步骤
    • 没有得到它@Goku 小部件可以帮助您显示所有步骤,不是吗?
    猜你喜欢
    • 1970-01-01
    • 2020-02-18
    • 1970-01-01
    • 2021-01-08
    • 2020-11-01
    • 2020-09-28
    • 2020-10-13
    • 2020-02-27
    • 1970-01-01
    相关资源
    最近更新 更多