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

Fix for 'dirty' error caused by scroll notifications during layout #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix for 'dirty' state caused by setState during build
  • Loading branch information
Patrick Wulfe committed Dec 18, 2023
commit e06e964254ecd4138a3a724b2eb85c617d30201a
8 changes: 5 additions & 3 deletions lib/src/scroll_shadow.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// [ScrollShadow] class
library flutter_scroll_shadow;

import 'dart:async';

import 'package:flutter/material.dart';

/// Wraps a scrollable child in `ScrollShadow`s.
Expand Down Expand Up @@ -63,7 +65,7 @@ class _ScrollShadowState extends State<ScrollShadow> {

set reachedStart(final bool value) {
if (_reachedStart == value) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
scheduleMicrotask(() {
setState(() => _reachedStart = value);
});
}
Expand All @@ -72,7 +74,7 @@ class _ScrollShadowState extends State<ScrollShadow> {

set reachedEnd(final bool value) {
if (_reachedEnd == value) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
scheduleMicrotask(() {
setState(() => _reachedEnd = value);
});
}
Expand Down Expand Up @@ -190,7 +192,7 @@ class _ScrollShadowState extends State<ScrollShadow> {

bool _handleNewMetrics(final ScrollMetrics metrics) {
if (_axis != metrics.axis) {
WidgetsBinding.instance.addPostFrameCallback((_) {
scheduleMicrotask(() {
setState(() => _axis = metrics.axis);
});
}
Expand Down