useScreen method

void useScreen(
  1. BuildContext context, {
  2. NikuButton base(
    1. NikuButton
    )?,
  3. NikuButton xs(
    1. NikuButton
    )?,
  4. NikuButton sm(
    1. NikuButton
    )?,
  5. NikuButton md(
    1. NikuButton
    )?,
  6. NikuButton lg(
    1. NikuButton
    )?,
  7. NikuButton xl(
    1. NikuButton
    )?,
})
inherited
void useScreen({
  // > 568px
  Widget Function(Niku)? base,
  // 568 - 640px
  Widget Function(Niku)? xs,
  // 640 - 768px
  Widget Function(Niku)? sm,
  // 768 - 920px
  Widget Function(Niku)? md,
  // 920 - 1024px
  Widget Function(Niku)? lg,
  // > 1024px
  Widget Function(Niku)? xl,
})

Implementation

void useScreen(
  BuildContext context, {
  // > 568px
  T Function(T)? base,
  // 568 - 640px
  T Function(T)? xs,
  // 640 - 768px
  T Function(T)? sm,
  // 768 - 920px
  T Function(T)? md,
  // 920 - 1024px
  T Function(T)? lg,
  // > 1024px
  T Function(T)? xl,
}) {
  final width = MediaQuery.of(context).size.width;

  if (width < 568) {
    if (base != null) apply = base(copied);

    return;
  }

  if (width < 640) {
    if (xs != null)
      apply = xs(self);
    else if (base != null) apply = base(self);

    return;
  }

  if (width < 720) {
    if (sm != null)
      apply = sm(self);
    else if (xs != null)
      apply = xs(self);
    else if (base != null) apply = base(self);

    return;
  }

  if (width < 920) {
    if (md != null)
      apply = md(self);
    else if (sm != null)
      apply = sm(self);
    else if (xs != null)
      apply = xs(self);
    else if (base != null) apply = base(self);

    return;
  }

  if (width < 1024) {
    if (lg != null)
      apply = lg(self);
    else if (md != null)
      apply = md(self);
    else if (sm != null)
      apply = sm(self);
    else if (xs != null)
      apply = xs(self);
    else if (base != null) apply = base(self);
  }

  if (xl != null)
    apply = xl(self);
  else if (lg != null)
    apply = lg(self);
  else if (md != null)
    apply = md(self);
  else if (sm != null)
    apply = sm(self);
  else if (xs != null)
    apply = xs(self);
  else if (base != null) apply = base(self);
}