useScreen method

void useScreen(
  1. BuildContext context, {
  2. T base(
    1. T
    )?,
  3. T xs(
    1. T
    )?,
  4. T sm(
    1. T
    )?,
  5. T md(
    1. T
    )?,
  6. T lg(
    1. T
    )?,
  7. T xl(
    1. T
    )?,
})
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);
}