dxvid-pts / miniplayer

A lightweight flutter package to simplify the creation of a miniplayer.
https://pub.dev/packages/miniplayer
MIT License
106 stars 79 forks source link

Overflow warnings in example #14

Closed shahmirzali49 closed 2 years ago

shahmirzali49 commented 3 years ago

A RenderFlex overflowed by 26 pixels on the bottom.

Screen Shot 2021-04-28 at 17 05 42
nwatab commented 3 years ago

same here. found a solution?

shahmirzali49 commented 3 years ago

@asterisk37n I'm not using like in example version, I just open issue for this error

nwatab commented 3 years ago

Thank you. I happens only during translation.

❯ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] VS Code (version 1.58.2) [✓] Connected device (2 available)

• No issues found!

bottomNavigationBar: ValueListenableBuilder(
    valueListenable: playerExpandProgress,
    builder: (BuildContext context, double height, Widget? child) {
      final value = _percentageFromValueInRange(
        min: _playerMinHeight,
        max: MediaQuery.of(context).size.height,
        value: height,
      );
      final double opacity =  _clipValueInRange(value: 1.0 - value, min: 0.0, max: 1.0);
      return SizedBox(
        height: kBottomNavigationBarHeight * (1 - value),
        child: Transform.translate(
          offset: Offset(0.0, kBottomNavigationBarHeight * value * 0.5),
          child: Opacity(opacity: opacity, child: child),
        ),
      );
    },
    child: BottomNavigationBar(...),
)

double _percentageFromValueInRange(
    {required final double min,
    required final double max,
    required final double value}) {
  return (value - min) / (max - min);
}

double _clipValueInRange(
    {required final double value,
    required final double min,
    required final double max}) {
  if (value < min) {
    return min;
  }
  if (value > max) {
    return max;
  }
  return value;
}

═╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════ The following assertion was thrown during layout: A RenderFlex overflowed by 29 pixels on the bottom.

The relevant error-causing widget was: BottomNavigationBar file:***

To inspect this widget in Flutter DevTools, visit: http://127.0.0.1:54097/#/inspector?uri=***

The overflowing RenderFlex has an orientation of Axis.vertical. The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex. Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size. This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView. The specific RenderFlex in question is: RenderFlex#8f1aa relayoutBoundary=up10 OVERFLOWING: creator: Column ← Padding ← Listener ← RawGestureDetector ← GestureDetector ← Semantics ← _RawMouseRegion ← MouseRegion ← Semantics ← _FocusMarker ← Focus ← _ActionsMarker ← ⋯ parentData: offset=Offset(0.0, 7.0) (can use size) constraints: BoxConstraints(0.0<=w<=137.1, 0.0<=h<=10.7) size: Size(137.1, 10.7) direction: vertical mainAxisAlignment: spaceBetween mainAxisSize: min crossAxisAlignment: center verticalDirection: down ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤ ════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: A RenderFlex overflowed by 29 pixels on the bottom.

Another exception was thrown: A RenderFlex overflowed by 29 pixels on the bottom.

image image

nwatab commented 3 years ago

I reproduced the overflow with the lib.zip from #1 a_mini_player_example_with_an_overflow_bug (1)

mrripp3r commented 3 years ago

Anyone got a work around yet?

dxvid-pts commented 2 years ago

I don't see this as a critical issue since it is not visible in production, but this is fixed in 2ad75d4f6f3f92b33ded418dc5c85f671ac94ed6

hpulst commented 2 years ago

Overflow warnings do still occur (tested on iOS Simulator).

chaevid commented 2 years ago

I solved this problem by adding the

MediaQuery.of(context).padding.bottom

with the height value of 0 on iPhone 8.

~/example/lib/main.dart

[Before]

...
          return SizedBox(
            height: kBottomNavigationBarHeight - kBottomNavigationBarHeight * value,
...

[After]

...
          return SizedBox(
            height: (kBottomNavigationBarHeight + MediaQuery.of(context).padding.bottom) -
                (kBottomNavigationBarHeight + MediaQuery.of(context).padding.bottom) * value,
...