Skip to content

Horizontal ListView in nested ListViews doesn't work #150236

@QuncCccccc

Description

@QuncCccccc

Steps to reproduce

  1. Run the sample code
  2. Scroll the horizontal list view

Expected results

Should be able to scroll horizontally.

Actual results

Doesn't scroll and the scroll bar for the vertical list view is highlighted. This issue happens on both iOS and web but only happens when I'm using trackpad.

Code sample

Code sample
import 'package:flutter/material.dart';

/// Flutter code sample for [Carousel].

void main() => runApp(const ExampleApp());

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Carousel Sample'),
        ),
        body: const Example(),
      ),
    );
  }
}

class Example extends StatefulWidget {
  const Example({super.key});

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        Container(
          width: 200,
          height: 200,
          color: Colors.amber[50],
        ),
        Center(
          child: ConstrainedBox(
            constraints: const BoxConstraints(maxHeight: 200),
            child: ListView(
              scrollDirection: Axis.horizontal,
              children: List.generate(20, (int index) {
                return ConstrainedBox(constraints: BoxConstraints.tightFor(width: 200), child: Card.outlined(child: SizedBox(width: 200, height: 200, child: Center(child: Text('Item $index')),),),);
              }),
            )
          ),
        ),
        Container(
          width: 200,
          height: 200,
          color: Colors.amber[100],
        ),
        Container(
          width: 200,
          height: 200,
          color: Colors.amber[200],
        ),
      ],
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2024-06-13.at.4.00.09.PM.mov

Might be related to #146654

CC: @HansMuller

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktopf: scrollingViewports, list views, slivers, etc.found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions