Skip to content

Add factory constructors to ScrollPhysics #192989

Closed

Description

@FMorschel

Use case

This way, instead of:

ListView.builder(
  physics: const AlwaysScrollableScrollPhysics(),

We could write:

ListView.builder(
  physics: const .alwaysScrollable(),

And similar.

Proposal

We should add one to each public subclass:

Image

CC @navaronbracke

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    f: scrollingViewports, list views, slivers, etc.
    and removed
    in triagePresently being triaged by the triage team
    on Sep 18, 2026
  2. navaronbracke commented on Sep 21, 2026

    @navaronbracke
    Contributor

    @FMorschel I had to do a double take, but isn't this just .new() everywhere?
    I.e. this works today without any changes

    import 'package:flutter/material.dart';
    
    void main() {
      const CarouselScrollPhysics carousel = .new();
      const FixedExtentScrollPhysics fixed = .new(parent: null);
    }

    You want named factories on ScrollPhysics itself?

  3. FMorschel commented on Sep 21, 2026

    @FMorschel
    ContributorAuthor

    You want named factories on ScrollPhysics itself?

    Yes exactly. Because that way we can use them in the Widget tree like at Listand similar.

  4. added
    P2Important issues not at the top of the work list
    on Sep 22, 2026
  5. github-actions commented on Oct 24, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions