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.36k stars 378 forks source link

Can't scroll to bottom if maxHeight > available height #231

Open magnuswikhog opened 3 years ago

magnuswikhog commented 3 years ago

Describe the bug I have a SlidingUpPanel containing a SingleChildScrollView, using panelBuilder and its provided scrollcontroller. I noticed that I can't scroll to the bottom of the contents if I set maxHeight of the panel to anything bigger than the available height (i.e. typically the screen height - AppBar height).

To Reproduce

        SlidingUpPanel(
          maxHeight: 2000,
          minHeight: 40,
          panelBuilder: (scrollController){
            return SingleChildScrollView(
              controller: scrollController,
              child: Column(
                children: List.generate(200, (index) => Text('index: $index'))
              ),
            );
          }
        );

Expected behavior To be able to scroll down to see "index: 199". Instead I can only scroll to "index: 116" (on my particular phone, results may vary).

Screenshots image

Additional context Appears to be solvable by wrapping the panel in a LayoutBuilder, and providing the constrained maxHeight from the builder to the panel:

        LayoutBuilder(
          builder: (context, constraints) {
            return SlidingUpPanel(
              maxHeight: constraints.maxHeight,
              minHeight: 40,
              panelBuilder: (scrollController){
                return SingleChildScrollView(
                  controller: scrollController,
                  child: Column(
                    children: List.generate(200, (index) => Text('index: $index'))
                  ),
                );
              }
            );
          }
        );

Smartphone (please complete the following information):

Sample main.dart

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

void main() {
  runApp(
    MyApp(),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Demo Home Page'),
      ),
      body: Stack(
        children: [
          SlidingUpPanel(
            maxHeight: 2000,
            minHeight: 40,
            panelBuilder: (scrollController){
              return SingleChildScrollView(
                controller: scrollController,
                child: Column(
                  children: List.generate(200, (index) => Text('index: $index'))
                ),
              );
            }
          )
        ],
      )

    );
  }
}
v-pavlovskyi commented 1 year ago

@magnuswikhog did you fix that?