【问题标题】:How to make UI in flutter like the image attached?如何使 UI 像附加的图像一样颤动?
【发布时间】:2022-11-13 22:10:46
【问题描述】:

在这方面的任何帮助将不胜感激。

谢谢

我尝试了不同的方法,但无法做到这样

【问题讨论】:

  • 你是在尊重步骤吗?你能包括你到目前为止尝试过的东西吗?
  • 我对颤动很陌生。我已经开始了,但无法弄清楚。
  • 尝试 Stepper 小部件,但可能会错过渐变 ui。您可能需要使用 Custompaint 创建小部件

标签: flutter


【解决方案1】:

您可以使用Stepper 小部件。您也可以查看im_stepper 包。

Stepper的文档示例


class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({super.key});

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  int _index = 0;

  @override
  Widget build(BuildContext context) {
    return Stepper(
      currentStep: _index,
      onStepCancel: () {
        if (_index > 0) {
          setState(() {
            _index -= 1;
          });
        }
      },
      onStepContinue: () {
        if (_index <= 0) {
          setState(() {
            _index += 1;
          });
        }
      },
      onStepTapped: (int index) {
        setState(() {
          _index = index;
        });
      },
      steps: <Step>[
        Step(
          title: const Text('Step 1 title'),
          content: Container(
              alignment: Alignment.centerLeft,
              child: const Text('Content for Step 1')),
        ),
        const Step(
          title: Text('Step 2 title'),
          content: Text('Content for Step 2'),
        ),
      ],
    );
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 2013-04-12
    • 1970-01-01
    • 2021-07-25
    • 1970-01-01
    • 2022-08-10
    • 2022-11-15
    相关资源
    最近更新 更多