Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.6.2 can not response events when widget in the header, such as Inkwell、Button etc. #75

Closed
realWayneZhang opened this issue May 11, 2022 · 16 comments

Comments

@realWayneZhang
Copy link

You can duplicate the issue by running the code as below.

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

class TabHeaderExample extends StatefulWidget {
  const TabHeaderExample({Key? key}) : super(key: key);

  @override
  State<TabHeaderExample> createState() => _TabHeaderExampleState();
}

class _TabHeaderExampleState extends State<TabHeaderExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Tab List Example'),),
      body: CustomScrollView(
        slivers: [
          _StickyHeaderList(index: 0),
          _StickyHeaderList(index: 1),
          _StickyHeaderList(index: 2),
          _StickyHeaderList(index: 3),
        ],
      ),
    );
  }
}

class _StickyHeaderList extends StatefulWidget  {
  final int index;
  const _StickyHeaderList({Key? key, required this.index}) : super(key: key);

  @override
  State<_StickyHeaderList> createState() => _StickyHeaderListState();
}

class _StickyHeaderListState extends State<_StickyHeaderList> with TickerProviderStateMixin {

  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 10, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return SliverStickyHeader(
      header: Container(
        color: Colors.white,
        height: 47,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Expanded(
              child: TabBar(
                isScrollable: true,
                controller: _tabController,
                indicatorColor: const Color(0xFF216DDF),
                indicatorSize: TabBarIndicatorSize.label,
                indicatorWeight: 2,
                indicatorPadding: EdgeInsets.only(bottom: 10),
                unselectedLabelColor: const Color(0xFF888888),
                unselectedLabelStyle: TextStyle(fontSize: 17),
                labelColor: const Color(0xFF216DDF),
                labelStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
                tabs: _createTabs(),
                onTap: (index) { print(index);},
              ),
            ),
            InkWell(
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.red,
                  boxShadow: [
                    BoxShadow(
                      color: Colors.white,
                      blurRadius: 8,
                      offset: Offset(-20, 0),
                    ),
                  ],
                ),
                padding: EdgeInsets.only(left: 5, right: 12),
                child: Row(
                  children: [
                    Text(
                      "全部",
                      style: TextStyle(color: const Color(0xFF101010), fontSize: 17),
                    ),
                  ],
                ),
              ),
              onTap: () {
                // Can not response
                print("1234567");
              },
            ),
          ],
        ),
      ),
      sliver: SliverList(
        delegate: SliverChildBuilderDelegate(
              (context, i) => ListTile(
            onTap: () {
              print('tile $i');
            },
            leading: CircleAvatar(
              child: Text('${widget.index}'),
            ),
            title: Text('List tile #$i'),
          ),
          childCount: 6,
        ),
      ),
    );
  }

  /// 创建Tabs
  List<Widget> _createTabs() {
    return ["我是tab", "我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab"].map((e) => Tab(text: e)).toList();
  }
}
@39499740
Copy link

I have the same problem

@39499740
Copy link

You can duplicate the issue by running the code as below.

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

class TabHeaderExample extends StatefulWidget {
  const TabHeaderExample({Key? key}) : super(key: key);

  @override
  State<TabHeaderExample> createState() => _TabHeaderExampleState();
}

class _TabHeaderExampleState extends State<TabHeaderExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Tab List Example'),),
      body: CustomScrollView(
        slivers: [
          _StickyHeaderList(index: 0),
          _StickyHeaderList(index: 1),
          _StickyHeaderList(index: 2),
          _StickyHeaderList(index: 3),
        ],
      ),
    );
  }
}

class _StickyHeaderList extends StatefulWidget  {
  final int index;
  const _StickyHeaderList({Key? key, required this.index}) : super(key: key);

  @override
  State<_StickyHeaderList> createState() => _StickyHeaderListState();
}

class _StickyHeaderListState extends State<_StickyHeaderList> with TickerProviderStateMixin {

  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 10, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return SliverStickyHeader(
      header: Container(
        color: Colors.white,
        height: 47,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Expanded(
              child: TabBar(
                isScrollable: true,
                controller: _tabController,
                indicatorColor: const Color(0xFF216DDF),
                indicatorSize: TabBarIndicatorSize.label,
                indicatorWeight: 2,
                indicatorPadding: EdgeInsets.only(bottom: 10),
                unselectedLabelColor: const Color(0xFF888888),
                unselectedLabelStyle: TextStyle(fontSize: 17),
                labelColor: const Color(0xFF216DDF),
                labelStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
                tabs: _createTabs(),
                onTap: (index) { print(index);},
              ),
            ),
            InkWell(
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.red,
                  boxShadow: [
                    BoxShadow(
                      color: Colors.white,
                      blurRadius: 8,
                      offset: Offset(-20, 0),
                    ),
                  ],
                ),
                padding: EdgeInsets.only(left: 5, right: 12),
                child: Row(
                  children: [
                    Text(
                      "全部",
                      style: TextStyle(color: const Color(0xFF101010), fontSize: 17),
                    ),
                  ],
                ),
              ),
              onTap: () {
                // Can not response
                print("1234567");
              },
            ),
          ],
        ),
      ),
      sliver: SliverList(
        delegate: SliverChildBuilderDelegate(
              (context, i) => ListTile(
            onTap: () {
              print('tile $i');
            },
            leading: CircleAvatar(
              child: Text('${widget.index}'),
            ),
            title: Text('List tile #$i'),
          ),
          childCount: 6,
        ),
      ),
    );
  }

  /// 创建Tabs
  List<Widget> _createTabs() {
    return ["我是tab", "我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab","我是tab"].map((e) => Tab(text: e)).toList();
  }
}

back to 0.6.1

@abellee
Copy link

abellee commented May 12, 2022

me too

@flicksoftdev
Copy link

I'm getting this is too

@azharbinanwar
Copy link

I was getting this error in 0.6.2,
I've solved my problem just by using the previous version.
flutter_sticky_header: 0.6.1

@ozz-rjq
Copy link

ozz-rjq commented May 13, 2022

same issue

1 similar comment
@xuhongfei
Copy link

same issue

@helloV7
Copy link

helloV7 commented May 19, 2022

pubspec.yaml file
flutter_sticky_header: ^0.6.1 to flutter_sticky_header: 0.6.1
then run flutter pub get

letsar added a commit that referenced this issue May 25, 2022
@letsar
Copy link
Owner

letsar commented May 25, 2022

It should be fixed in version 0.6.3, can you try?

@KanybekMomukeyev
Copy link

2 day researched this issue, and finally find the reason

@therealcisse
Copy link

@letsar

This issue still exists when the sticky header is in a snapped state. It becomes impossible to click on anything rendered with the header.

Thanks for amazing library!

@letsar
Copy link
Owner

letsar commented May 30, 2022

@amsayk have you a complete example I could run? I didn't reproduced what you described

@therealcisse
Copy link

@letsar Here is a main.dart to reproduce it. The only package installed is flutter_sticky_header version 0.6.3.

It works if you comment out the CupertinoSliverNavigationBar . Otherwise, no other factor seems to matter.

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

import 'package:flutter_sticky_header/flutter_sticky_header.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      home: Scaffold(
        body: MyHomePage(title: 'Flutter Demo Home Page'),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: CustomScrollView(
        primary: true,
        physics: const AlwaysScrollableScrollPhysics(parent: ClampingScrollPhysics()),
        slivers: [
          CupertinoSliverNavigationBar(
            key: const ValueKey('NavBar'),
            previousPageTitle: 'Back',
            border: Border(
              bottom: BorderSide(
                color: Theme.of(context).dividerColor,
                width: 1.0, // 0.0 means one physical pixel
              ),
            ),
            stretch: true,
            largeTitle: const Text('Details'),
          ),
          SliverStickyHeader.builder(
            builder: (context, state) => ListTile(
              tileColor: Colors.grey,
              shape: RoundedRectangleBorder(side: const BorderSide(color: Colors.black, width: 1), borderRadius: BorderRadius.circular(0)),
              leading: const CircleAvatar(),
              title: const Text('Title 1'),
              trailing: MouseRegion(
                cursor: SystemMouseCursors.click,
                child: GestureDetector(
                  child: Icon(
                    Icons.settings,
                    size: 28.0,
                    color: Theme.of(context).primaryColor,
                  ),
                  onTapDown: (details) => print('onTapDown: $details'),
                ),
              ),
            ),
            sliver: SliverList(
              delegate: SliverChildListDelegate(
                List.generate(
                  10,
                  (index) => Container(
                    child: SizedBox(
                      height: 250.0,
                      child: Center(child: Text('Element $index')),
                    ),
                  ),
                ),
              ),
            ),
          ),
          SliverStickyHeader.builder(
            builder: (context, state) => ListTile(
              tileColor: Colors.grey,
              shape: RoundedRectangleBorder(side: const BorderSide(color: Colors.black, width: 1), borderRadius: BorderRadius.circular(0)),
              leading: const CircleAvatar(),
              title: const Text('Title 2'),
              trailing: MouseRegion(
                cursor: SystemMouseCursors.click,
                child: GestureDetector(
                  child: Icon(
                    Icons.settings,
                    size: 28.0,
                    color: Theme.of(context).primaryColor,
                  ),
                  onTapDown: (details) => print('onTapDown: $details'),
                ),
              ),
            ),
            sliver: SliverList(
              delegate: SliverChildListDelegate(
                List.generate(
                  10,
                  (index) => Container(
                    child: SizedBox(
                      height: 250.0,
                      child: Center(child: Text('Element $index')),
                    ),
                  ),
                ),
              ),
            ),
          ),
          SliverStickyHeader.builder(
            builder: (context, state) => ListTile(
              tileColor: Colors.grey,
              shape: RoundedRectangleBorder(side: const BorderSide(color: Colors.black, width: 1), borderRadius: BorderRadius.circular(0)),
              leading: const CircleAvatar(),
              title: const Text('Title 3'),
              trailing: MouseRegion(
                cursor: SystemMouseCursors.click,
                child: GestureDetector(
                  child: Icon(
                    Icons.settings,
                    size: 28.0,
                    color: Theme.of(context).primaryColor,
                  ),
                  onTapDown: (details) => print('onTapDown: $details'),
                ),
              ),
            ),
            sliver: SliverList(
              delegate: SliverChildListDelegate(
                List.generate(
                  10,
                  (index) => Container(
                    child: SizedBox(
                      height: 250.0,
                      child: Center(child: Text('Element $index')),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Hope it helps!

@mherbert93
Copy link

Experiencing the same issue with versions above 0.6.1.

@Tony0205
Copy link

Tony0205 commented Jun 30, 2022

I faced the same issue.
But this issue seems to have been resolved in version flutter_sticky_header: ^0.6.3.
and it works fine with version flutter_sticky_header: 0.6.1 too.

@letsar letsar closed this as completed Jul 13, 2022
@GabrielAraujo
Copy link

It was happening with me on 0.6.4 but working perfectly on 0.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests