flutter-defer-pointer icon indicating copy to clipboard operation
flutter-defer-pointer copied to clipboard

Not working with padding arround

Open EArminjon opened this issue 3 years ago • 1 comments

 return Padding(
      padding: const EdgeInsets.only(top: 16),
      child: DeferredPointerHandler(
        child: SizedBox(
          width: 100,
          height: 100,
          child: Stack(
            clipBehavior: Clip.none,
            children: [
              // Hang button off the bottom of the content
              Positioned(
                bottom: -30,
                child: DeferPointer(child: TextButton(onPressed: () => print("lol"), child: Text("lol"))),
              ),
              // Content
              Positioned.fill(
                child: Container(
                  decoration: BoxDecoration(color: Colors.green, boxShadow: [
                    BoxShadow(color: Colors.black.withOpacity(1), blurRadius: 4, spreadRadius: 4),
                  ]),
                ),
              ),
            ],
          ),
        ),
      ),
    );

image

The lol button is not clickable outside the green block.

EArminjon avatar Dec 13 '21 22:12 EArminjon

I think this is because the padding is tightly wrapping your content, giving you only 16px of more area to detect hits.

Try swapping the Padding and the DeferredPointerHandler? Or just put a single DeferredPointerHandler at the top of your app to keep it simple if you want.

esDotDev avatar Dec 22 '21 22:12 esDotDev