Skip to content

prevent slide dragging up #45

@anasmano

Description

@anasmano

Hello, this not a bug or other issues, but this is just a question.

Is it possible to prevent the slide from dragging up when scrolling through builder content (the content builder can still be scrolled normally) in my case is a CustomScrollView (see my code below)) where the slide is at minHeight position ?

Thanks in advance.

class _MyListViewWrapperState extends State<MyListViewWrapper> {
  final List<String> items =
      List<String>.generate(50, (i) => 'Entri Daftar ${i + 1}');

 
  ScrollController sc = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey.shade200,
      appBar: AppBar(
        title: Text('Simple Example'),
      ),
      body: Stack(
        children: <Widget>[
          SlidingSheet(
            minHeight: 500,
            headerBuilder: (context, state) {
              return Container(
                width: 40,
                height: 20,
                decoration: BoxDecoration(
                  color: Colors.grey[300],
                  borderRadius: BorderRadius.circular(2),
                ),
              );
            },
            elevation: 8,
            cornerRadius: 16,
            snapSpec: const SnapSpec(
              snap: true,
              snappings: [112, 400, double.infinity],
              positioning: SnapPositioning.pixelOffset,
            ),
            builder: (context, state) {
              return CustomScrollView(
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                slivers: [
                  const SliverToBoxAdapter(
                    child: SizedBox(height: 30),
                  ),
                  const SliverToBoxAdapter(
                    child: Padding(
                      padding: EdgeInsets.all(16.0),
                      child: Text(
                        'Starting Slivers',
                        style: TextStyle(
                            fontSize: 20, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),

                  // SliverList
                  SliverList(
                    delegate: SliverChildBuilderDelegate(
                      (BuildContext context, int index) {
                        return ListTile(
                          title: Text('Item #$index'),
                        );
                      },
                      childCount: 30,
                    ),
                  ),
                  // SliverToBoxAdapter
                  const SliverToBoxAdapter(
                    child: Padding(
                      padding: EdgeInsets.all(16.0),
                      child: Text(
                        'Grid Section',
                        style: TextStyle(
                            fontSize: 20, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),

                  // SliverGrid (2 kolom)
                  SliverGrid(
                    delegate: SliverChildBuilderDelegate(
                      (BuildContext context, int index) {
                        return Card(
                          margin: const EdgeInsets.all(8.0),
                          color: Colors.teal[100 * ((index % 8) + 1)],
                          child: Center(
                            child: Text('Grid Item #$index'),
                          ),
                        );
                      },
                      childCount: 8,
                    ),
                    gridDelegate:
                        const SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2, // 2 kolom
                      mainAxisSpacing: 10.0, // Spasi vertikal
                      crossAxisSpacing: 10.0, // Spasi horizontal
                      childAspectRatio: 1.0, // Rasio lebar/tinggi
                    ),
                  ),

                  // SliverToBoxAdapter penutup
                  const SliverToBoxAdapter(
                    child: SizedBox(height: 50),
                  ),
                ],
              );
            },
          ),
        ],
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions