fujidaiti / smooth_sheets

Sheet widgets with smooth motion and great flexibility.
https://pub.dev/packages/smooth_sheets
MIT License
180 stars 13 forks source link

A _ContentIdleScrollDrivenSheetActivity was used after being disposed. #103

Open yfming93 opened 2 months ago

yfming93 commented 2 months ago

0.4.1 version work well. But 0.4.2 version work error.

image

Code are present below:

import 'dart:ui';

import 'package:app/core/app_export.dart';
import 'package:app/location/map_self.dart';
import 'package:smooth_sheets/smooth_sheets.dart';

class ContentSheet extends StatelessWidget {
  const ContentSheet({super.key, required this.ct,});

  final Widget ct;

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {

        final minH = constraints.maxHeight - mapH - 40;
        final minSheetExtent = Extent.pixels(minH);
        // final parentHeight = constraints.maxHeight;
        final sheetHeight = constraints.maxHeight - MediaQuery.of(context).padding.top ;

        final sheetPhysics = StretchingSheetPhysics(
          parent: SnappingSheetPhysics(
            // spring: SpringDescription.withDampingRatio(
            //   mass: 1,
            //   stiffness: 100.0,
            //   ratio: 1.1,
            // ),
            snappingBehavior: SnapToNearest(
              snapTo: [
                minSheetExtent,
                const Extent.proportional(1),
              ],
            ),
          ),
        );

        return ScrollableSheet(
          physics: sheetPhysics,
          minExtent: minSheetExtent,
          initialExtent: minSheetExtent,
          child: SizedBox(
            height: sheetHeight,
            // child: ListView(
            //   padding: EdgeInsets.zero,
            //   shrinkWrap: true,
            //   physics: NeverScrollableScrollPhysics(),
            //   children: [
            //     ct,
            //   ],
            // ),

            child: SingleChildScrollView(
              child: Container(
                height: 1000,
                color: C.red,
              ),
            ),
            // child: ct,
          ),
        );
      },
    );
  }
fujidaiti commented 2 months ago

Thank you for your reporting, but I couldn't reproduce the error even with v0.4.2. Here's the code that I've used.

Code ```dart import 'package:flutter/material.dart'; import 'package:smooth_sheets/smooth_sheets.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: Stack( children: [ Placeholder(), ContentSheet(), ], ), ), ); } } const mapH = 200.0; class ContentSheet extends StatelessWidget { const ContentSheet({ super.key, // required this.ct, }); // final Widget ct; @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { final minH = constraints.maxHeight - mapH - 40; final minSheetExtent = Extent.pixels(minH); // final parentHeight = constraints.maxHeight; final sheetHeight = constraints.maxHeight - MediaQuery.of(context).padding.top; final sheetPhysics = StretchingSheetPhysics( parent: SnappingSheetPhysics( // spring: SpringDescription.withDampingRatio( // mass: 1, // stiffness: 100.0, // ratio: 1.1, // ), snappingBehavior: SnapToNearest( snapTo: [ minSheetExtent, const Extent.proportional(1), ], ), ), ); return ScrollableSheet( physics: sheetPhysics, minExtent: minSheetExtent, initialExtent: minSheetExtent, child: SizedBox( height: sheetHeight, // child: ListView( // padding: EdgeInsets.zero, // shrinkWrap: true, // physics: NeverScrollableScrollPhysics(), // children: [ // ct, // ], // ), child: SingleChildScrollView( child: Container( height: 1000, color: Colors.red, ), ), // child: ct, ), ); }, ); } } ```

Can you give me more information about the missing part of your code, such as the widget that surrounds the ContentSheet widget?