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

initialScrollIndex not work ! #59

Open
mwlt68 opened this issue Aug 20, 2023 · 0 comments
Open

initialScrollIndex not work ! #59

mwlt68 opened this issue Aug 20, 2023 · 0 comments

Comments

@mwlt68
Copy link

mwlt68 commented Aug 20, 2023

When i pass value from list count it don't scroll. It show first item and no error.

Expanded _bodyMessages(ChatState state) {
    var messageCount = state.messages.length;
    var model = Expanded(
      child: StickyGroupedListView<ConversationMessageModel, DateTime>(
        elements: state.messages,
        order: StickyGroupedListOrder.ASC,
        groupBy: (ConversationMessageModel element) => DateTime(
          element.createdAt!.year,
          element.createdAt!.month,
          element.createdAt!.day,
        ),
        groupComparator: (DateTime value1, DateTime value2) =>
            value1.compareTo(value2),
        itemComparator: (ConversationMessageModel element1,
                ConversationMessageModel element2) =>
            element1.createdAt!.compareTo(element2.createdAt!),
        floatingHeader: true,
        groupSeparatorBuilder: _getGroupSeparator,
        indexedItemBuilder: (context, element, index) =>
            _getItem(element, index, state.messages.length, state.currentUser!),
        itemScrollController: _scrollController,
        initialScrollIndex: messageCount,
      ),
   
);

    return model;
  }

When i give initialScrollIndex as digit it scroll but give an error !

initialScrollIndex: 5,

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building LayoutBuilder:
'package:scrollable_positioned_list/src/positioned_list.dart': Failed assertion: line 49 pos 16:
'(positionedIndex == 0) || (positionedIndex < itemCount)': is not true.

The relevant error-causing widget was:
LayoutBuilder
LayoutBuilder:file:///home/mevlut/.pub-cache/hosted/pub.dev/scrollable_positioned_list-0.3.8/lib/src/scrollable_positioned_list.dart:408:12

When the exception was thrown, this was the stack:
#2 new PositionedList (package:scrollable_positioned_list/src/positioned_list.dart:49:16)
#3 _ScrollablePositionedListState.build. (package:scrollable_positioned_list/src/scrollable_positioned_list.dart:422:28)
#4 _LayoutBuilderElement._layout.layoutCallback (package:flutter/src/widgets/layout_builder.dart:119:77)
#5 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2682:19)
#6 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:153:12)
#7 RenderObject.invokeLayoutCallback. (package:flutter/src/rendering/object.dart:2300:59)
#8 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1056:15)
#9 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2300:14)
#10 RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:228:7)
#11 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:313:5)
#12 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#13 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#14 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#15 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:595:43)
#16 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:622:12)
#17 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#18 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#19 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#20 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:903:45)
#21 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:938:32)
#22 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#23 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#24 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:297:14)
#25 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#26 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#27 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12)
#28 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1080:7)
#29 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
#30 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:410:14)
#31 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#32 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#33 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#34 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#35 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#36 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#37 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1467:11)
#38 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#39 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#40 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#41 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#42 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#43 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#44 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#45 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#46 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#47 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#48 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#49 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#50 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#51 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#52 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#53 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#54 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#55 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#56 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#57 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#58 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#59 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#60 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#61 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#62 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#63 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#64 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#65 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#66 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#67 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3813:14)
#68 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#69 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#70 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#71 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#72 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#73 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:856:15)
#74 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2027:7)
#75 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1020:18)
#76 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:516:19)
#77 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
#78 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#79 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#80 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
#81 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#82 _invoke (dart:ui/hooks.dart:145:13)
#83 PlatformDispatcher._drawFrame (d

art:ui/platform_dispatcher.dart:338:5)
#84 _drawFrame (dart:ui/hooks.dart:112:31)
(elided 2 frames from class _AssertionError)

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