google / flutter.widgets

https://pub.dev/packages/flutter_widgets
BSD 3-Clause "New" or "Revised" License
1.38k stars 488 forks source link

[scrollable_positioned_list] initialScrollIndex broken with shrinkWrap #345

Open kulture-rob-snider opened 2 years ago

kulture-rob-snider commented 2 years ago

Problem description

When using initialScrollIndex other than 0 in combination with shrinkWrap, the list is not rendered correctly.

Steps to reproduce

sample code ``` import 'package:flutter/material.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; void main() { runApp( const ScrollablePositionedListExample(), ); } class ScrollablePositionedListExample extends StatelessWidget { const ScrollablePositionedListExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'ScrollablePositionedList Example', theme: ThemeData(primarySwatch: Colors.blue), home: Material( child: SafeArea( child: ScrollablePositionedList.separated( initialScrollIndex: 2, shrinkWrap: true, reverse: true, itemCount: 5, itemBuilder: (_, index) => ListTile(title: Text('$index')), separatorBuilder: (_, __) => const Divider(), ), ), ), ); } } ```

Expected behavior

I would expect that a continuous list is displayed with all items visible.

Actual behavior

reverse: true ![Simulator Screen Shot - iPhone 11 Pro Max - 2022-04-27 at 14 25 25](https://user-images.githubusercontent.com/53707285/165594407-b8bc7363-3b0f-42da-b373-e84ea98ab308.png)
reverse: false ![Simulator Screen Shot - iPhone 11 Pro Max - 2022-04-27 at 14 25 18](https://user-images.githubusercontent.com/53707285/165594336-2f31a59c-a542-4e1e-8676-712c21574840.png)

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.3 21E230 darwin-arm, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.65.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!
jaymanned commented 2 years ago

+1

jaymanned commented 2 years ago

@kulture-rob-snider

Did you find a fix or workaround for this issue?

Best

Sagarz2422 commented 2 years ago

Guys any update on this one facing the same issue.

magamal commented 3 months ago

any updates about this issue