Coder Social home page Coder Social logo

jackjonson / flutter_sliding_up_panel Goto Github PK

View Code? Open in Web Editor NEW
30.0 2.0 17.0 2.19 MB

A sliding up panel widget.

License: Apache License 2.0

Java 0.67% Objective-C 2.99% Dart 87.56% Ruby 8.78%
panel panel-widget animationcontroller elevation sliding-up-panel flutter flutter-package

flutter_sliding_up_panel's Introduction

flutter_sliding_up_panel

A sliding up panel widget which can be used to show or hide content, beautiful and simple.

demo

Getting Started

Null safety

dependencies:
  flutter_styled_toast: ^2.0.1

Previous version

dependencies:
  flutter_sliding_up_panel: ^1.2.1
import 'package:flutter_sliding_up_panel/flutter_sliding_up_panel.dart';
Stack(
  children: <Widget>[
    Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.settings),
            onPressed: () {
              widget.onSetting?.call();
            },
          )
        ],
      ),
      body: Container(
        child:Center(
          child:Text('This is content'),
        ),
      ),
    ),
    SlidingUpPanelWidget(
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 15.0),
        decoration: ShapeDecoration(
          color: Colors.white,
          shadows: [BoxShadow(blurRadius: 5.0,spreadRadius: 2.0,color: const Color(0x11000000))],
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10.0),
              topRight: Radius.circular(10.0),
            ),
          ),
        ),
        child: Column(
          children: <Widget>[
            Container(
              color: Colors.white,
              alignment: Alignment.center,
              height: 50.0,
              child: Row(
                children: <Widget>[
                  Icon(Icons.menu,size: 30,),
                  Padding(
                    padding: EdgeInsets.only(left: 8.0,),
                  ),
                  Text(
                    'click or drag',
                  )
                ],
                mainAxisAlignment: MainAxisAlignment.center,
              ),
            ),
            Divider(
              height: 0.5,
              color: Colors.grey[300],
            ),
            Flexible(
              child: Container(
                child: ListView.separated(
                  controller: scrollController,
                  physics: ClampingScrollPhysics(),
                  itemBuilder: (context, index) {
                    return ListTile(
                      title: Text('list item $index'),
                    );
                  },
                  separatorBuilder: (context, index) {
                    return Divider(
                      height: 0.5,
                    );
                  },
                  shrinkWrap: true,
                  itemCount: 20,
                ),
                color: Colors.white,
              ),
            ),
          ],
          mainAxisSize: MainAxisSize.min,
        ),
      ),
      controlHeight: 50.0,
      anchor: 0.4,
      panelController: panelController,
      onTap: (){
         ///Customize the processing logic
         if(SlidingUpPanelStatus.expanded==panelController.status){
            panelController.collapse();
         }else{
            panelController.expand();
         }
      },  //Pass a onTap callback to customize the processing logic when user click control bar.
      enableOnTap: true,//Enable the onTap callback for control bar.
      dragDown: (details){
         print('dragDown');
      },
      dragStart: (details){
         print('dragStart');
      },
      dragCancel: (){
         print('dragCancel');
      },
      dragUpdate: (details){
         print('dragUpdate,${panelController.status==SlidingUpPanelStatus.dragging?'dragging':''}');
      },
      dragEnd: (details){
         print('dragEnd');
      },
    ),
  ],
);

SlidingUpPanelWidget param

property description
child Widget (Not Null)(required) (Child widget)
controlHeight double (Not Null)(required) (The height of the control bar which could be used to drag or click to control this panel)
animationController AnimationController (The animation that controls the bottom sheet's position.)
panelController SlidingUpPanelController (Not Null)(required) (The controller to control panel)
onStatusChanged OnSlidingUpPanelStatusChanged (Called when the this panel status changed)
elevation double (default 8.0) (Elevation of the panel)
panelStatus SlidingUpPanelStatus (default SlidingUpPanelStatus.collapsed) (Panel status)
anchor double (default 0.5) (The fraction of anchor position, which is from 0 to 1.0)
onTap VoidCallback (default is a build-in callback) (Void callback when click control bar)
enableOnTap bool (Not Null)(default is true) (Enable or disable the tap callback for control bar)
dragDown OnSlidingUpPanelDragDown (default is null) (Drag down listener)
dragStart OnSlidingUpPanelDragStart (default is null) (Drag start listener)
dragUpdate OnSlidingUpPanelDragUpdate (default is null) (Drag update listener)
dragCancel OnSlidingUpPanelDragCancel (default is null) (Drag cancel listener)
dragEnd OnSlidingUpPanelDragEnd (default is null) (Drag end listener)

Example

example

flutter_sliding_up_panel's People

Contributors

efraespada avatar jackjonson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_sliding_up_panel's Issues

Exception when sliding panel

The following assertion was thrown while dispatching notifications for SlidingUpPanelController:
AnimationController.animateTo() called after AnimationController.dispose()
AnimationController methods should not be used after calling dispose.
'package:flutter/src/animation/animation_controller.dart':
Failed assertion: line 533 pos 7: '_ticker != null'

When the exception was thrown, this was the stack: 
#2      AnimationController.animateTo (package:flutter/src/animation/animation_controller.dart:533:7)
#3      _SlidingUpPanelWidgetState.expand (package:flutter_sliding_up_panel/sliding_up_panel_widget.dart:332:26)
#4      _SlidingUpPanelWidgetState.handlePanelStatusChanged (package:flutter_sliding_up_panel/sliding_up_panel_widget.dart:365:9)
#5      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:351:24)
#6      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:456:5)
#7      _SlidingUpPanelWidgetState.expand (package:flutter_sliding_up_panel/sliding_up_panel_widget.dart:334:28)
#8      _SlidingUpPanelWidgetState._handleDragEnd (package:flutter_sliding_up_panel/sliding_up_panel_widget.dart:297:9)
#9      DragGestureRecognizer._checkEnd.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:521:47)
#10     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24)
#11     DragGestureRecognizer._checkEnd (package:flutter/src/gestures/monodrag.dart:521:5)
#12     DragGestureRecognizer.didStopTrackingLastPointer (package:flutter/src/gestures/monodrag.dart:426:9)
#13     OneSequenceGestureRecognizer.stopTrackingPointer (package:flutter/src/gestures/recognizer.dart:446:9)
#14     DragGestureRecognizer._giveUpPointer (package:flutter/src/gestures/monodrag.dart:435:5)
#15     DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:354:7)
#16     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#17     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#18     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
#19     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#20     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#21     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:460:19)
#22     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22)
#23     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11)
#24     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7)
#25     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5)
#26     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7)
#27     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7)
#28     _invoke1 (dart:ui/hooks.dart:167:13)
#29     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
#30     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
(elided 2 frames from class _AssertionError)
The SlidingUpPanelController sending notification was: SlidingUpPanelController#6b6cf(SlidingUpPanelStatus.expanded)

Couldn't set Initial height.

It would have been better to have an initial height parameter in the arguments.
If the user specifies the initialHeight argument, the Slding up panel with that Height.
Otherwise, it is set to minHeight.

I couldn't figure out how get this behaviour. Could you tell?

Expanded

Hi. How i can off full screen expanded?
Thank you.

Anchor value behave differently on different phones

Hello,

I'me developing an app on a Xiaomi Mi 9T and using the anchor value of 0.3 for the panel. The positioning is perfect and the behavior is as expected.

However, when tried run my app on a LG v30, the bottom part of the panel was partially hidden on the bottom of the screen, as if the "resolution" of the screen was misscalculated. So i've changed the anchor to 0.4; it solved the issue on the LG v30, but broke the visualization on my Xiaomi Mi 9T, making the panel got higher (and getting the element from the bottom of the panel away from the bottom of the screen).

There is an issue related to this or some kind of elegant workaround?

Warning: Operand of null-aware operation '!'

I am using this package, and it is giving me the following error, when run my project:

`: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
../…/lib/sliding_up_panel_widget.dart:174

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../../Development/flutter/packages/flutter/lib/src/widgets/binding.dart').
    package:flutter/…/widgets/binding.dart:1
    WidgetsBinding.instance!.addPostFrameCallback((_) => _initData(context));`

Feature : disable onTap detection

Hello,

Very good work and the simplest to use !
Can you add a boolean to choose if we want to use or not the onTap ?

onTap: () { if (SlidingUpPanelStatus.anchored == widget.panelController.status) { collapse(); } else if (SlidingUpPanelStatus.collapsed == widget.panelController.status) { anchor(); } else if (SlidingUpPanelStatus.expanded == widget.panelController.status) { collapse(); } else { collapse(); } },

Null Safety

Has this package Null Safety?
If not, is it planned to be implemented in the near future?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.