horizontal_blocked_scroll_physics 3.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

Horizontal Blocked ScrollPhysics #

Build Status License: MIT Pub

A ScrollPhysics class that blocks movement in the horizontal axis.

How to use it #

The API of this ScrollPhysics is fairly straighforward.

We have two different classes:

  • LeftBlockedScrollPhysics: will block left movements.
  • RightBlockedScrollPhysics: will block right movements.

Blocking movement #


This will allow the content to be scrolled to the right and will block any scroll to the left.

There's one exception, though. You can see here that the user is swiping to the left (which is blocked) but the screen will be able to move to the left if the movement is not completed. Note that the text will go back to the center.


Alternatively, if you want to block movement to the right and allow scrolling to the left:


Why are we exposing two classes #

You may have notice that we're exposing two classes instead of only one that uses properties to change the physics behavior. That's because of an optimization in the Scrollable class that doesn't allow to use the same type, even if it's a new instance, in order to change the Scrollable physics behavior.

The physics can be changed dynamically, but new physics will only take effect if the class of the provided object changes. Merely constructing a new instance with a different configuration is insufficient to cause the physics to be reapplied. (This is because the final object used is generated dynamically, which can be relatively expensive, and it would be inefficient to speculatively create this object each frame to see if the physics should be updated.)

That's why Flutter has specific ScrollPhysics like NeverScrollableScrollPhysics and AlwaysScrollableScrollPhysics.

[3.0.0] - 2020-05-26. #

  • Provide custom classes for left and right blockage to avoid issues with [scrollable.dart] optimizations.

[2.0.0] - 2020-05-26. #

  • Fixed issue with overscroll.
  • Introduced a breaking change as allowRecovery is not already supported.

[1.1.4] - 2020-05-22. #

  • Fixed image reduction for pub.dev.

[1.1.3] - 2020-05-22. #

  • Reduced image size in readme.

[1.1.2] - 2020-05-22. #

  • Fixed link to images in readme.

[1.1.1] - 2020-05-22. #

  • Fixed errors in overscroll calculation when movement is too fast.

[1.1.0] - 2020-05-18. #

  • Improved the blocking movement. Now it allows the view to recover in case the swipe movement is not fully completed.
  • Fixed the way to detect horizontal movement.

[1.0.2] - 2020-05-15. #

  • Relying on the ScrollPhysics parent class.
  • Fixed right logic

[1.0.1] - 2020-05-14. #

  • Added pedantic analysis options.

[1.0.0] - 2020-05-13. #

  • Initial release.


import 'package:flutter/material.dart';
import 'package:horizontal_blocked_scroll_physics/horizontal_blocked_scroll_physics.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      home: MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: PageView(
        physics: RightBlockedScrollPhysics(),
        children: <Widget>[

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  horizontal_blocked_scroll_physics: ^3.0.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:horizontal_blocked_scroll_physics/horizontal_blocked_scroll_physics.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart


  • horizontal_blocked_scroll_physics that is a package requiring null.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
pedantic ^1.8.0+1 1.9.0 1.9.2
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies