美文网首页
MultiShower

MultiShower

作者: 熊大_小咩 | 来源:发表于2019-11-12 17:58 被阅读0次

MultiShower的使用

var decorations = [TextDecoration.none,TextDecoration.lineThrough,
  TextDecoration.overline,TextDecoration.underline];

var show = MultiShower(
    decorations, (decoration) => Text("dawn",
          style: TextStyle(
              fontSize: 20, //字号
              decoration: decoration),
        ));

源码

import 'package:flutter/material.dart';

class MultiShower extends StatelessWidget {
  MultiShower(
    this.list,
    this.call, {
    this.width = 110,
    this.height = 110 * 0.618,
    this.infos,
    this.color = Colors.cyanAccent,
  });

  final List list;
  final List<String> infos;
  final Function call;
  final double width;
  final double height;
  final Color color;

  @override
  Widget build(BuildContext context) {
    var li = <Widget>[];
    for (var i = 0; i < list.length; i++) {
      var child = Container(
          margin: EdgeInsets.all(7),
          color: color,
          width: width,
          height: height,
          child: call(list[i]));
      li.add(Column(
        children: <Widget>[
          child,
          Text(infos != null ? infos[i] : list[i].toString().split(".")[1])
        ],
      ));
    }
    return Wrap(
      children: li,
    );
  }
}

相关文章

网友评论

      本文标题:MultiShower

      本文链接:https://www.haomeiwen.com/subject/cxsqictx.html