首页 > 解决方案 > 是否可以在 Flutter 中使用 CustomScrollView 中的 InkWell

问题描述

当我像这样在 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 组件?我应该怎么做才能解决它?

标签: flutter

解决方案


InkWell尝试包裹SliverToBoxAdapter


推荐阅读