Dart Use a setter for operations that conceptually change a property Dart Use a setter for operations that conceptually change a property dart dart

Dart Use a setter for operations that conceptually change a property


I guess it wants you to do:

set scrollToPosition(int selectedPagePosition) {  position.value = selectedPagePosition;}

and then callers would use scrollToPosition = position instead of scrollToPosition(position).

Assuming that scrollToPosition() performs some scrolling action, personally I prefer it looking like a function call, and I'd suppress the lint with

// ignore: use_setters_to_change_properties

(However, if it were named position, a setter might be more fitting.)