Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollablePositionedList inside ScrollView with initialScrollIndex > 0 removes widgets entirely from the view #545

Open
thedeukalion opened this issue Oct 8, 2024 · 0 comments

Comments

@thedeukalion
Copy link

I'm trying to wrap a PositionedScrollableList inside a parent ScrollView and use "shrinkWrap", but doing so makes the indexes before initialStartIndex disappear. Instead of scrolling to that position it seems to remove everything before the startIndex. It works the same inside a CustomScrollView. It only works when ScrollablePositionedList is primary scroll inside a Scaffold for me.

Problem description

scrollable_positioned_list: ^0.3.8

Steps to reproduce

void main() async {

  WidgetsFlutterBinding.ensureInitialized();

  runApp(const TestApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: ScrollablePositionedList.separated(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            itemCount: 50,
            padding: const EdgeInsets.all(16),
            initialScrollIndex: 5,
            itemBuilder: (context, index) {
              return Container(
                color: index % 2 == 0 ? Colors.red : Colors.yellow,
                child: Text("Index: $index"),
              );
            },
            separatorBuilder: (context, index) => const SizedBox(height: 16,),
          ),
        ),
      ),
    );
  }
}

Expected behavior

Setting the initialScrollIndex to 5 I also expected to see 1-4 as well in the list just "above it".

Actual behavior

It starts at Index: 5 and skips 1-4 entirely. It's not even visible in the UI.

Example

Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant