Skip to content

[Android]: StretchingOverscrollIndicator clips ListView while scrolling horizontally #103491

@definev

Description

@definev

Details

I'm using a custom clip for the visible shadow but when I use StretchingOverscrollIndicator it automatically clips my ListView.

Target Platform: Android
Target OS version/browser: 12

Logs

Logs
Screen.Recording.2022-05-11.at.20.38.34.mov

flutter doctor -v

[] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm (Rosetta), locale en-VN)
     Flutter version 3.0.0 at /Users/daiduong/fvm/versions/stable
     Upstream repository https://github.com/flutter/flutter.git
     Framework revision ee4e09cce0 (3 days ago), 2022-05-09 16:45:18 -0700
     Engine revision d1b9a6938a
     Dart version 2.17.0
     DevTools version 2.12.2

[] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
     Android SDK at /Users/daiduong/Library/Android/sdk
     Platform android-32, build-tools 32.0.0
     Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
     Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
     All Android licenses accepted.

[] Xcode - develop for iOS and macOS (Xcode 13.3)
     Xcode at /Applications/Xcode.app/Contents/Developer
     CocoaPods version 1.11.3

[] Chrome - develop for the web
     Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[] Android Studio (version 2021.2)
     Android Studio at /Applications/Android Studio.app/Contents
     Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
     Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
     Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[] VS Code (version 1.67.1)
     VS Code at /Applications/Visual Studio Code.app/Contents
     Flutter extension version 3.40.0

[] Connected device (3 available)
     sdk gphone arm64 (mobile)  emulator-5554  android-arm64   Android 11 (API 30) (emulator)
     macOS (desktop)            macos          darwin-arm64    macOS 12.3.1 21E258 darwin-arm (Rosetta)
     Chrome (web)               chrome         web-javascript  Google Chrome 101.0.4951.64

[] HTTP Host Availability
     All required HTTP hosts are available

 No issues found!
The code My reproduce code
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: Scaffold(
          appBar: AppBar(title: const Text('Issue')),
          body: Padding(
            padding: const EdgeInsets.symmetric(vertical: 30),
            child: Column(
              children: [
                NumberSeclectBar(
                  title: "ScrollTest",
                  value: 1,
                  onChanged: (_) {},
                ),
                const SizedBox(height: 10),
                NumberSeclectBar(
                  title: "ScrollTest",
                  value: 1,
                  onChanged: (_) {},
                ),
                const SizedBox(height: 10),
                NumberSeclectBar(
                  title: "ScrollTest",
                  value: 1,
                  onChanged: (_) {},
                ),
                const SizedBox(height: 10),
                NumberSeclectBar(
                  title: "ScrollTest",
                  value: 1,
                  onChanged: (_) {},
                ),
                const SizedBox(height: 10),
                NumberSeclectBar(
                  title: "ScrollTest",
                  value: 1,
                  onChanged: (_) {},
                ),
              ],
            ),
          ),
      ),
    );
  }
}

class NumberSeclectBar extends StatelessWidget {
  const NumberSeclectBar({
    Key? key,
    required this.title,
    required this.value,
    required this.onChanged,
    this.required = true,
    this.subtitle,
  }) : super(key: key);

  final String title;
  final String? subtitle;
  final int value;
  final ValueChanged<int> onChanged;
  final bool required;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return SizedBox(
      height: 45,
      child: Row(
        children: [
          SizedBox(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(title),
                if (subtitle != null)
                  Text(
                    subtitle!,
                    style: theme.textTheme.bodySmall,
                  ),
              ],
            ),
            width: 100,
          ),
          const SizedBox(width: 10),
          Expanded(
            child: ClipPath(
              clipper: CustomClip(),
              child: ListView.builder(
                padding: EdgeInsets.zero,
                scrollDirection: Axis.horizontal,
                clipBehavior: Clip.none,
                itemBuilder: (context, index) {
                  return Padding(
                    padding: const EdgeInsets.only(right: 10),
                    child: AspectRatio(
                      aspectRatio: 1,
                      child: InkWell(
                        onTap: () {
                          if (required) {
                            onChanged(index + 1);
                            return;
                          }
                          onChanged(index);
                        },
                        borderRadius: BorderRadius.circular(10),
                        child: AnimatedContainer(
                          duration: const Duration(milliseconds: 300),
                          curve: Curves.ease,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(10),
                            color:
                                (required ? value == index + 1 : value == index)
                                    ? theme.colorScheme.primary
                                    : theme.colorScheme.surface,
                            boxShadow: [
                              BoxShadow(
                                blurRadius: 12,
                                color: theme.colorScheme.primary.withOpacity(1),
                              ),
                            ],
                          ),
                          child: Center(
                            child: Text(
                              required
                                  ? (index + 1).toString()
                                  : index.toString(),
                              style: theme.textTheme.bodyMedium!.copyWith(
                                color: (required
                                        ? value == index + 1
                                        : value == index)
                                    ? theme.colorScheme.onPrimary
                                    : theme.colorScheme.onSurface,
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                  );
                },
              ),
            ),
          ),
        ],
      ),
    );
  }
}

class CustomClip extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = Path();
    path.addRect(
      Rect.fromCenter(
        center: size.center(Offset.zero),
        width: size.width + 20,
        height: size.height + 30,
      ),
    );
    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper<Path> oldClipper) => false;
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions