Pakete, Repositories und App-Kategorien suchen

Cover von snap_scroll_physics
Paketdetailsv0.0.1+3

snap_scroll_physics

Scroll-Physik, um den Benutzer scroll an verschiedenen Offset zu fangen

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
9
Likes
76
Pub-Punkte
140

Paket installieren

flutter pub add snap_scroll_physics

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein Flutter-Paket, das Scroll-Physik bereitstellt, die die Scrollposition an bestimmte Offsetwerte anpasst und die Benutzererfahrung in scrollbaren Widgets verbessert. Es ermöglicht eine präzise Steuerung des Scrollverhaltens und ist ideal für Karussell-artige Oberflächen oder Rasterlayouts, bei denen eine Ausrichtung an vordefinierte Positionen erforderlich ist. Das Paket unterstützt alle wichtigen Plattformen und integriert sich nahtlos mit Standard-ScrollViews. Es erweitert das eingebaute Physiksystem von Flutter und bietet anpassbare Snap-Intervalle sowie reibungslose Übergänge.

Anwendungsfälle

  • Karussell-Schieberegler
  • Rasterlayouts mit Ausrichtung
  • Formularfeldnavigation
  • Produkt-Carousels
  • Benutzerdefiniertes Scroll-Snapping
  • Interaktive Tutorials

Hauptmerkmale

  • An vordefinierte Verschiebungen anpassen
  • Glatte Übergangsanimationen
  • Plattformübergreifende Unterstützung
  • Erweitert die Standard-Physik
  • Konfigurierbare Snap-Intervalle
  • Einfache Integration mit ScrollViews

Geeignet für

  • Entwickler, die interaktive Scroll-Schnittstellen erstellen
  • Designer, die eine präzise Scroll-Ausrichtung benötigen
  • Apps mit Karussell- oder Registerbasiertem Navigation
  • Projekte, die benutzerdefinierte Scrollverhalten erfordern
  • Teams, die mehrere Plattformen anstreben

Hinweise

  • Kann Anpassungen erfordern, um die optimale Benutzererfahrung zu gewährleisten
  • Kann bei unzureichender Verwaltung mit anderen Physiksystemen kollidieren
  • Nicht ideal für kontinuierliches Scrollen
  • Leistungsbeeinträchtigung bei vielen Snap-Punkten
  • Nur auf scrollbare Widgets beschränkt

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

Snap Scroll Physics

pub package

When building scrollable views, sometimes you would prefer that the scroll stopped at a given offset, or that it avoids to stop inside some area. This package allows you to implement this on any Flutter scroll view.

This kind of behaviour can be seen in any iOS app using the UIKit/SwiftUI Navigation bar, also with custom headers inside some popular apps like Twitter, Chrome, Gmail, Google Photos, Apple Music, Facebook and many more!

snap_scroll

physics: SnapScrollPhysics(
    snaps: [
        Snap(200, distance: 50), // If the scroll offset is expected to stop between 150-250 the scroll will snap to 200,
        Snap(200, leadingDistance: 50), // If the scroll offset is expected to stop  between 150-200 the scroll will snap to 200,
        Snap(200, trailingDistance: 50), // If the scroll offset is expected to stop between 150-200 the scroll will snap to 200,
        Snap(200, trailingDistance: 50), // If the scroll offset is expected to stop between 150-200 the scroll will snap to 200,
        Snap.avoidZone(0, 200), // If the scroll offset is expected to stop between 0-200, the scroll will snap to 0 if the expected one is between 0-99, and to 200 if it is between 100-200,
        Snap.avoidZone(0, 200, delimiter: 50), // If the scroll offset is expected to stop between 0-200, the scroll will snap to 0 if the expected one is between 0-49, and to 200 if it is between 50-200
    ]
),
physics: SnapScrollPhysics.cupertinoAppBar, // Default values for the Cupertino appbar

https://user-images.githubusercontent.com/19904063/116775316-b67b8f80-aa62-11eb-9ae1-58da68a381e4.mp4

https://user-images.githubusercontent.com/19904063/116775452-56391d80-aa63-11eb-95ae-f8fd8154cbc9.mp4

IMPORTANT! Sadly ScrollPhysics are not reactivily updated, so if you change the values, they won't be automatically updated. See #80051.

This can be temporaly fixed by this, while is discouraged in production if no changes are needed at runtime:


List<Snap> getSnaps() {
    return [
       Snap(200), // Hot reload works
    ];
}
@override
  Widget build(BuildContext context) {
    return CustomScrollView(
      physics: SnapScrollPhysics.builder(getSnaps),
      slivers: [
       // ....
      ],
    );
  }

Kategorien

Quell-Repository

Projekte, die dieses Paket verwenden