FunnelChart constructor

FunnelChart({
  1. Key? key,
  2. required int layerCount,
  3. required int markerCount,
  4. required BrnFunnelLayerPainter layerPainter,
  5. required MarkerBuilder builder,
  6. FunnelShape shape = FunnelShape.leftAndRight,
  7. double maxLayerWidth = 200,
  8. double minLayerWidth = 0,
  9. double layerHeight = 40,
  10. double layerMargin = 0,
  11. Offset childOffset = Offset.zero,
  12. MarkerAlignment alignment = MarkerAlignment.right,
})

Implementation

FunnelChart({
  Key? key,
  required this.layerCount,
  required this.markerCount,
  required this.layerPainter,
  required MarkerBuilder builder,
  this.shape = FunnelShape.leftAndRight,
  this.maxLayerWidth = 200,
  this.minLayerWidth = 0,
  this.layerHeight = 40,
  this.layerMargin = 0,
  this.childOffset = Offset.zero,
  this.alignment = MarkerAlignment.right,
})  : assert(maxLayerWidth >= minLayerWidth),
      assert(layerCount - markerCount == 0 || layerCount - markerCount == 1),
      assert(() {
        if (shape == FunnelShape.leftOrRight &&
            alignment == MarkerAlignment.center) {
          debugPrint(
              '当shape为FunnelShape.LeftOrRight时,alignment为MarkerAlignment.center无效');
        }
        return true;
      }()),
      super(
          key: key,
          children: () {
            List<Widget> children = [];
            for (int i = 0; i < markerCount; i++) {
              children.add(builder(i));
            }
            return children;
          }());