Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 当我将GridView小部件用作ListView的子项时,滚动控件仅对ListView渲染区域处于活动状态&;不是从GridView区域_Flutter_Dart - Fatal编程技术网

Flutter 当我将GridView小部件用作ListView的子项时,滚动控件仅对ListView渲染区域处于活动状态&;不是从GridView区域

Flutter 当我将GridView小部件用作ListView的子项时,滚动控件仅对ListView渲染区域处于活动状态&;不是从GridView区域,flutter,dart,Flutter,Dart,5。我有一个滚动问题。外部容器列表视图 滚动很好,但是当我抓取gridView元素时,滚动效果不起作用。我在这里错过了什么?(下方GIF) HomeScreen()具有HomeBody()小部件;HomeBody()具有ListView,其子对象是BuildSectionContainers(),其子对象是服务小部件 类HomeBody扩展了无状态小部件{ @凌驾 小部件构建(构建上下文){ 最终healthService=提供者(上下文); 最终服务=healthService.serv

5。我有一个滚动问题。外部容器列表视图 滚动很好,但是当我抓取gridView元素时,滚动效果不起作用。我在这里错过了什么?(下方GIF)

HomeScreen()具有HomeBody()小部件;HomeBody()具有ListView,其子对象是BuildSectionContainers(),其子对象是服务小部件



类HomeBody扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
最终healthService=提供者(上下文);
最终服务=healthService.services;
返回列表视图(
儿童:[
//
BuildSectionContainer(
健康服务:健康服务,
服务:服务,,
章节标题:“服务”,
子:容器(
身高:245,
子项:BuildGeneralServicesGrid(
健康服务:健康服务,
服务:服务,,
),
),
),
//
BuildSectionContainer(
健康服务:健康服务,
服务:服务,,
章节标题:“应急服务”,
子:容器(
身高:245,
子项:BuildEmergencyServicesGrid(
健康服务:健康服务,
服务:服务,,
),
),
),       
],
);
}
}

class BuildEmergencyServicesGrid扩展了无状态小部件{
const BuildEmergencyServicesGrid({
钥匙?,钥匙,
需要这项服务,
需要这个服务,
}):super(key:key);
最终健康服务;
最终名单服务;
@凌驾
小部件构建(构建上下文){
返回GridView.builder(
itemCount:healthService.services.length,
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(
交叉轴计数:2,
横轴间距:1,
主轴间距:1,
主办方:120,,
),
itemBuilder:(上下文,索引)=>GestureDetector(
孩子:卡片(
颜色:主题。背景。原色。不透明度(0.1),
子:列(
mainAxisAlignment:mainAxisAlignment.center,
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
容器(
填充:常数边集全部(8.0),
子项:服务[index]。图标,
),
容器(
填充:常量边集。对称(水平:8.0),
子:文本(
服务[索引]。服务名称,
样式:Theme.of(context).textTheme.bodyText2,
textAlign:textAlign.center,
),
),
],
),
),
onTap:(){
导航器.of(上下文).push(MaterialPageRoute(
生成器:(上下文)=>AudioConsultation(),
));
},
),
);
}
}

发生此问题的原因是gridview干扰了listview的滚动。您可以将Gridview的Physical属性设置为以解决此问题

GridView.builder(
//禁用网格的滚动
物理学:NeverscrollableScroll物理学(),
//您剩余的代码
),

能否为
BuildEmergencyServicesGrid
class HomeScreem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Stethoscope',
          style: TextStyle(
              color: Theme.of(context).accentColor,
              fontSize: 24,
              fontFamily: GoogleFonts.pacifico().fontFamily,
              letterSpacing: 1.5),
        ),
        centerTitle: true,
      ),
      // APP BODY
      body: HomeBody(),
    );
  }
}
class HomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final healthService = Provider.of<HealthServices>(context);
    final service = healthService.services;

    return ListView(
      children: [
        //
        BuildSectionContainer(
          healthService: healthService,
          service: service,
          sectionTitle: 'SERVICES',
          child: Container(
            height: 245,
            child: BuildGeneralServicesGrid(
              healthService: healthService,
              service: service,
            ),
          ),
        ),

        //
        BuildSectionContainer(
          healthService: healthService,
          service: service,
          sectionTitle: 'EMERGENCY SERVICES',
          child: Container(
            height: 245,
            child: BuildEmergencyServicesGrid(
              healthService: healthService,
              service: service,
            ),
          ),
        ),       
      ],
    );
  }
}
class BuildEmergencyServicesGrid extends StatelessWidget {
  const BuildEmergencyServicesGrid({
    Key? key,
    required this.healthService,
    required this.service,
  }) : super(key: key);

  final HealthServices healthService;
  final List<HealthService> service;

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      itemCount: healthService.services.length,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        crossAxisSpacing: 1,
        mainAxisSpacing: 1,
        mainAxisExtent: 120,
      ),
      itemBuilder: (context, index) => GestureDetector(
        child: Card(
          color: Theme.of(context).primaryColor.withOpacity(0.1),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Container(
                padding: const EdgeInsets.all(8.0),
                child: service[index].icon,
              ),
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 8.0),
                child: Text(
                  service[index].serviceName,
                  style: Theme.of(context).textTheme.bodyText2,
                  textAlign: TextAlign.center,
                ),
              ),
            ],
          ),
        ),
        onTap: () {
          Navigator.of(context).push(MaterialPageRoute(
            builder: (context) => AudioConsultation(),
          ));
        },
      ),
    );
  }
}