Skip to content

Conversation

@24bartixx
Copy link
Member

@24bartixx 24bartixx commented Jan 6, 2026

The issue was that the accesibility widget with cards was had circular progress indicator when it was loading data. Then the indicator was changing to SizedBox.shink()

  1. height > 0
  2. height = 0 or height >>> 0
  3. weird jump

I implemented cache to store previous accesibility that is fetched asynchrounously causing this loading.
Moreover, I refactor the accesibiltiy list to load the card widgets lazily and used column instead of ListView (it's already inside CustomScrollView and there is not that many cards to render them dynamically imo) for perf.


Important

Implements caching and refactors accessibility list to prevent scrolling bug and improve performance in active_accessibility_modes_repository.dart.

  • Behavior:
    • Implements caching in ActiveAccessibilityModesRepository to store previous accessibility data, preventing unnecessary re-fetching.
    • Refactors accessibility list to load card widgets lazily using Column instead of ListView for performance improvement.
  • Repository:
    • Changes activeAccessibilityModesRepository to a class ActiveAccessibilityModesRepository with caching logic in active_accessibility_modes_repository.dart.

This description was created by Ellipsis for 77dd3d6. You can customize this summary. It will automatically update as commits are pushed.

@24bartixx 24bartixx self-assigned this Jan 6, 2026
@24bartixx 24bartixx linked an issue Jan 6, 2026 that may be closed by this pull request
Copy link
Member

@simon-the-shark simon-the-shark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this looks acceptable, but I would try one more thing to see if we could get same results without custom imperative cache, if you'd allow

Comment on lines 108 to 125
AccessibilityInformationCard createCard({
required String icon,
required int level,
required String? comment,
required String peopleLabel,
}) {
return AccessibilityInformationCard(
icon: icon,
color: DigitalGuideConfig.accessibilityLevelColors[level],
text:
comment ??
context.localize.accessibility_card_information(
prefix,
accessibilityLevelType(level.toString()),
peopleLabel,
),
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a function when it can be a private widget (this is builder methods anti-pattern)?

you can use inheritance if you don't want to repeat the build methods

class AccessibilityLevelCard extends AccessibilityInformationCard {
  _AccessibilityLevelCard({
    required BuildContext context,
    required String icon,
    required int level,
    required String? comment,
    required String peopleLabel,
    required String prefix,
    super.key,
  }) : super(
          icon: icon,
          color: DigitalGuideConfig.accessibilityLevelColors[level],
          text: comment ??
              context.localize.accessibility_card_information(
                prefix,
                accessibilityLevelType(level.toString()),
                peopleLabel,
              ),
        );
}

(or a new widget with build method is 100% ok as well)

Comment on lines 101 to 107
Map<ModeWithKey, AccessibilityInformationCard> _getCardsMap(
BuildContext context, {
required AccessibilityInformationLevelsInput levels,
required AccessibilityInformationOptionalCommentsInput? comments,
required String prefix,
required String Function(String) accessibilityLevelType,
}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating a method that returns a map I would just perfer to have a declarative-style switch (even inline in the build)

Comment on lines 94 to 98
return currentModesAsync.when(
loading: () => buildCards(cache),
error: (error, stack) => Center(child: Text("Error: $error")),
data: buildCards,
);
Copy link
Member

@simon-the-shark simon-the-shark Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I'm not saying that the cache you've built is not needed. It might be. We can go with it if it is needed truly. But could you try if something like that WITHOUT custom imperative cache that at least I believe should have very similar effects to what you've had done with the cache here:

switch (currentModesAsync) {
      AsyncError(:final error, :final stackTrace) => // error widget,
      AsyncValue(:final value) when value != null => buildCards(value) // this case should cover both, normal `AsyncData` case and `AsyncLoading` which has value from a previous render (that's how riverpod at least worked in the 2.0 version, not sure how about 3.0),
      _ => // actual loading cause no data is present (value == null), 
    };

afaik this should use the previous value even when refreshing so as far as i understand your code, very similar thing. not sure if 1:1 but very similar. could you try?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if the keepAlive: true is crucial you should probably add it to activeAccessibilityModesRepository or whatever is needed

@24bartixx 24bartixx force-pushed the fix/digital-guide-scrolling-bug branch from 805b714 to 77dd3d6 Compare January 16, 2026 16:46
@pull-request-size pull-request-size bot added size/S and removed size/L labels Jan 16, 2026
@24bartixx
Copy link
Member Author

I managed to do this changing only riverpod repo

@simon-the-shark simon-the-shark merged commit ffa88eb into main Jan 17, 2026
6 checks passed
@simon-the-shark simon-the-shark deleted the fix/digital-guide-scrolling-bug branch January 17, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ad. "Przewodnik 2" - scroll view weird bug

3 participants