createInnerMarginDivides static method

List<NamedLine> createInnerMarginDivides(
  1. PercentGetter marginPercent, {
  2. NamedLine? fromStartLine,
  3. NamedLine? toEndLine,
  4. bool includeStartEnd = false,
})

创建内双边距线

Implementation

static List<NamedLine> createInnerMarginDivides(PercentGetter marginPercent, {
  NamedLine? fromStartLine,
  NamedLine? toEndLine,
  bool includeStartEnd = false }){
  NamedLine fromStart = fromStartLine ?? NamedLine.percent(0.0, name: NAME_START);
  NamedLine toEnd = toEndLine ?? NamedLine.percent(1.0, name: NAME_END);
  // assert(marginPercent < toEnd.percent - fromStart.percent);
  // if(fromStart.percent + marginPercent >= toEnd.percent - marginPercent) return [];
  var sampleMarginPercent = marginPercent(Size.square(1.0));
  List<NamedLine> excludeStartEnd = [
      NamedLine.expression(fromStart + marginPercent,
        name: '$NAME_MARGIN-$NAME_START:(1/1)=>$sampleMarginPercent',
      ),
      // NamedLine.result(
      //   name: '$NAME_MARGIN-$NAME_START:(1/1)=>$sampleMarginPercent',
      //   percentGetter: (size)=>fromStart.percentGetter(size) + marginPercent(size),
      //   literalGetter: fromStart.literalGetter
      // ),
      NamedLine.expression(toEnd - marginPercent,
        name: '$NAME_MARGIN-$NAME_END:(1/1)=>$sampleMarginPercent',
      ),
      // NamedLine.result(
      //   name: '$NAME_MARGIN-$NAME_END:(1/1)=>$sampleMarginPercent',
      //   percentGetter: (size)=>toEnd.percentGetter(size) - marginPercent(size),
      //   literalGetter: toEnd.literalGetter
      // )
    ];
  return includeStartEnd ? [
    NamedLine.rename(rename: '$NAME_MARGIN-$NAME_START', copy: fromStart),
    ...excludeStartEnd,
    NamedLine.rename(rename: '$NAME_MARGIN-$NAME_END', copy: toEnd)
  ] : excludeStartEnd;
}