是否可以在颤振中的 CustomScrollView 中使用 InkWell

时间:2021-02-28 13:13:42

标签: flutter

当我像这样在 CustomScrollView 中嵌入 InkWell 时:

child: SizedBox(
                height: 500.0,
                child: CustomScrollView(slivers: <Widget>[
                  InkWell(
                    onTap: () => {},
                    child: Padding(
                      padding: const EdgeInsets.only(bottom: 8.0),
                      child: Container(
                        child: Text(
                          item.subName == "" ? "Comment" : item.subName,
                          style: Theme.of(context).textTheme.headline5.copyWith(
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ),
                    ),
                  ),

                  SliverPadding(
                    padding: const EdgeInsets.symmetric(vertical: 8.0),
                    sliver: viewService.buildComponent("articlelist"),
                  )
                ]),
              ),
            ),

显示此错误:

======== Exception caught by widgets library =======================================================
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was: 
  CustomScrollView file:///Users/dolphin/Documents/GitHub/cruise-open/lib/src/page/channel/channeldetail_component/view.dart:96:24
====================================================================================================

我应该在 CustomScrollView 中使用 InkWell 吗? CustomScrollView 只能使用 sliver 组件吗?我该怎么做才能修复它?

1 个答案:

答案 0 :(得分:1)

尝试将 InkWell 包裹在 SliverToBoxAdapter