initChildren function

List<Widget> initChildren(
  1. List<WeActionSheetItem> children,
  2. dynamic onChange,
  3. Color borderColor, {
  4. Alignment align = Alignment.center,
})

Implementation

List<Widget> initChildren(
    List<WeActionSheetItem> children, onChange, Color borderColor,
    {Alignment align = Alignment.center}) {
  // 列表
  final List<Widget> list = [];

  // 循环children
  for (int index = 0; index < children.length; index++) {
    // 边框
    if (index != 0) {
      list.add(Divider(height: 1, color: borderColor));
    }

    list.add(InkWell(
        onTap: () {
          onChange(index);
        },
        child: DecoratedBox(
            decoration: BoxDecoration(),
            child: Align(
                alignment: align,
                child: SizedBox(
                    child: Padding(
                        padding: EdgeInsets.only(
                            top: _topPadding,
                            right: _leftPadding,
                            bottom: _topPadding,
                            left: _leftPadding),
                        child: DefaultTextStyle(
                            style:
                                TextStyle(fontSize: 16.0, color: Colors.black),
                            child: toTextWidget(
                                children[index].label, 'children中的值')!)))))));
  }

  return list;
}