akshathjain / sliding_up_panel

A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
https://pub.dartlang.org/packages/sliding_up_panel
Other
1.38k stars 381 forks source link

Full Height with Scaffold, no safe area #28

Open MadReal opened 5 years ago

MadReal commented 5 years ago

Hello, I'm trying to extend the Panel to "full height" when it is open

SlidingUpPanel(
  minHeight: UiPlayerShrinked._kPlayerBodyHeight,
  maxHeight: MediaQuery.of(context).size.height,
  controller: _pc,
  onPanelOpened: () => updateIsPlayerExtendedShowing(true),
  onPanelClosed: () => updateIsPlayerExtendedShowing(false),
  collapsed: buildShrinkedPlayer(playingBeat, context),
  panel: Scaffold(
    body: Text('Scaffold'),
  ),

Although there are a couple of problems:

First is this error:

flutter: #11     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #12     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #13     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #14     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #15     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #16     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #17     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #18     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #19     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
package:flutter/…/rendering/proxy_box.dart:105
flutter: #20     RenderObject.layout 
package:flutter/…/rendering/object.dart:1644
flutter: #21     RenderConstrainedOverflowBox.performLayout 
package:flutter/…/rendering/shifted_box.dart:571
flutter: #22     RenderObject._layoutWithoutResize 
package:flutter/…/rendering/object.dart:1519
flutter: #23     PipelineOwner.flushLayout 
package:flutter/…/rendering/object.dart:766
flutter: #24     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame 
package:flutter/…/rendering/binding.dart:347
flutter: #25     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame 
package:flutter/…/widgets/binding.dart:701
flutter: #26     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback 
package:flutter/…/rendering/binding.dart:286
flutter: #27     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback 
package:flutter/…/scheduler/binding.dart:1012
flutter: #28     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame 
package:flutter/…/scheduler/binding.dart:952
flutter: #29     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame 
package:flutter/…/scheduler/binding.dart:864
flutter: #33     _invoke  (dart:ui/hooks.dart:219:10)
flutter: #34     _drawFrame  (dart:ui/hooks.dart:178:3)
flutter: (elided 5 frames from class _AssertionError and package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter:   RenderCustomMultiChildLayoutBox#09649 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
flutter:   creator: CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
flutter:   _InkFeatures-[GlobalKey#ad7ea ink renderer] ← NotificationListener<LayoutChangedNotification> ←
flutter:   PhysicalModel ← AnimatedPhysicalModel ← Material ← PrimaryScrollController ← _ScaffoldScope ←
flutter:   Scaffold ← ⋯
flutter:   parentData: <none> (can use size)
flutter:   constraints: BoxConstraints(0.0<=w<=414.0, h=896.0)
flutter:   size: Size(414.0, 896.0)
flutter: This RenderObject had the following descendants (showing up to depth 5):
flutter:   _RenderLayoutBuilder#0aed1 relayoutBoundary=up9
flutter:     _RenderScrollSemantics#2b11b relayoutBoundary=up10
flutter:       RenderPointerListener#b3ac8 relayoutBoundary=up11
flutter:         RenderSemanticsGestureHandler#4a540 relayoutBoundary=up12
flutter:           RenderPointerListener#d0ada relayoutBoundary=up13
flutter:   RenderConstrainedBox#adef0 relayoutBoundary=up9
flutter:     RenderSemanticsAnnotations#3a36e relayoutBoundary=up10
flutter:       RenderAnnotatedRegion<SystemUiOverlayStyle>#61585 relayoutBoundary=up11
flutter:         RenderPhysicalModel#e90d0 relayoutBoundary=up12
flutter:           _RenderInkFeatures#4d6ad relayoutBoundary=up13
flutter:   RenderFlex#a74c8 relayoutBoundary=up9 NEEDS-PAINT
flutter:     RenderStack#834eb relayoutBoundary=up10 NEEDS-PAINT
flutter:       RenderLimitedBox#3e5ec relayoutBoundary=up11
flutter:         RenderConstrainedBox#de0f0 relayoutBoundary=up12
flutter:       RenderLimitedBox#78b88 relayoutBoundary=up11
flutter:         RenderConstrainedBox#e7caa relayoutBoundary=up12
flutter:       RenderSemanticsGestureHandler#5ff96 relayoutBoundary=up11 NEEDS-PAINT
flutter:         RenderPointerListener#86019 relayoutBoundary=up12 NEEDS-PAINT
flutter:           RenderConstrainedBox#54ac0 relayoutBoundary=up13 NEEDS-PAINT
flutter:     RenderDecoratedBox#24077 relayoutBoundary=up10
flutter:       RenderConstrainedBox#227f5 relayoutBoundary=up11
flutter:         RenderPadding#c4b38 relayoutBoundary=up12
flutter:           RenderFlex#64816 relayoutBoundary=up13
flutter:   RenderStack#02564 relayoutBoundary=up9
flutter:     RenderTransform#35b38 relayoutBoundary=up10
flutter:       RenderTransform#c3d02 relayoutBoundary=up11
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: A RenderFlex overflowed by 10 pixels on the bottom.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 423 pos 16: 'bodyMaxHeight <= math.max(0.0, looseConstraints.maxHeight - contentTop)': is not true.
flutter: Another exception was thrown: Updated layout information required for _RenderLayoutBuilder#0aed1 relayoutBoundary=up9 NEEDS-LAYOUT to calculate semantics.
    [C61.1 903ABA02-99A7-41A4-B22F-87E88066A736 192.168.1.117:62932<->18.194.48.246:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 30.893s, DNS @0.000s took 0.001s, TCP @0.003s took 0.031s, TLS took 0.069s
    bytes in/out: 5047/1673, packets in/out: 8/6, rtt: 0.031s, retransmitted packets: 0, out-of-order packets: 0

The second issue is that there is no "safe area". I'm actually trying to emulate a "view" when the panel is open, with AppBar and Body but I can't achieve that because the content is pushed to the very edges

akshathjain commented 5 years ago

@MadReal Can you attach a sample main.dart file that reproduces this issue?

MadReal commented 5 years ago

Here it is

import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';

main() {
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Example',
      theme: ThemeData(
          brightness: Brightness.dark,
          primaryColor: Colors.blueAccent,
          accentColor: Colors.blueAccent,
          canvasColor: Colors.black54,
          fontFamily: 'opensans'),
      home: Home(),
    ),
  );
}

class Home extends StatefulWidget {
  const Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  bool showBottomBar = true;

  void setShowBottomBar(bool value) {
    setState(() {
      showBottomBar = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        extendBody: true,
        appBar: AppBar(title: Text('Example')),
        body: Center(child: Text('Example Body')),
        bottomNavigationBar: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            _BuildSlidingUpPanel(setShowBottomBar: setShowBottomBar),
            if (showBottomBar)
              CupertinoTabBar(
                items: [
                  BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('Tab')),
                  BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('Tab')),
                  BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('Tab')),
                  BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('Tab')),
                  BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('Tab'))
                ],
              ),
          ],
        ));
  }
}

class _BuildSlidingUpPanel extends StatelessWidget {
  static const _kPlayerBodyHeight = 58.0;
  static const _kPlayerPaddingTop = 5.0;
  final _pc = PanelController();
  final Function(bool) setShowBottomBar;

  _BuildSlidingUpPanel({this.setShowBottomBar});

  @override
  Widget build(BuildContext context) => SlidingUpPanel(
        minHeight: _kPlayerBodyHeight,
        maxHeight: MediaQuery.of(context).size.height,
        controller: _pc,
        onPanelSlide: (double value) {
          setShowBottomBar(value == 0);
        },
        collapsed: Stack(
          overflow: Overflow.visible,
          children: [
            // blurred background
            ClipRect(
              child: BackdropFilter(
                filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
                child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  // onTap: playerStatus.pc.open,
                  child: Container(
                    padding: EdgeInsets.only(top: _kPlayerPaddingTop),
                    color: Colors.red.withAlpha(120),
                    width: double.infinity,
                    child: Row(
                      children: [
                        SizedBox(width: 10),
                        Expanded(
                            child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                              Text('Swipe to open', overflow: TextOverflow.ellipsis),
                            ])),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
        panel: Scaffold(body: Text('body')),
      );
}
MadReal commented 5 years ago

@akshathjain any update? Do you see the error too?

akshathjain commented 5 years ago

@MadReal I've been able to reproduce the issue. I'm currently looking into what is causing it.

ShiroYacha commented 4 years ago

this seems to be related to other issues which is causing the bottom of the body to be covered by a navigation bar... any quick workaround to this? I have been trying to add paddings of kBottomNavigationBarHeight but it's not enough it seems...

sander48k commented 1 year ago

has this ever been resolved?

I'm having this same issue. It seems that the SlidingUpPanel uses a Stack widget with a height of the entire screen. So, to calculate the visible area height you need to take into account the height of the navigation bar, status bar, toolbar, etc.