Answers for "disable scrolling flutter"

2

flutter disable left side scrolling

class CustomScrollPhysics extends ScrollPhysics {
  CustomScrollPhysics({this.parent}) : super(parent: parent);

  final ScrollPhysics? parent;
  bool isGoingLeft = false;

  @override
  CustomScrollPhysics applyTo(ScrollPhysics? ancestor) {
    return CustomScrollPhysics(parent: buildParent(ancestor));
  }

  @override
  double applyPhysicsToUserOffset(ScrollMetrics position, double offset) {
    isGoingLeft = offset.sign < 0;
    return offset;
  }

  @override
  double applyBoundaryConditions(ScrollMetrics position, double value) {
    //print("applyBoundaryConditions");
    assert(() {
      if (value == position.pixels) {
        throw FlutterError(
            '$runtimeType.applyBoundaryConditions() was called redundantly.n'
            'The proposed new position, $value, is exactly equal to the current position of the '
            'given ${position.runtimeType}, ${position.pixels}.n'
            'The applyBoundaryConditions method should only be called when the value is '
            'going to actually change the pixels, otherwise it is redundant.n'
            'The physics object in question was:n'
            '  $thisn'
            'The position object in question was:n'
            '  $positionn');
      }
      return true;
    }());
    if (value < position.pixels &&
        position.pixels <= position.minScrollExtent) {
      return value - position.pixels;
    }
    if (position.maxScrollExtent <= position.pixels &&
        position.pixels < value) {
      return value - position.pixels;
    }
    if (value < position.minScrollExtent &&
        position.minScrollExtent < position.pixels) {
      return value - position.minScrollExtent;
    }

    if (position.pixels < position.maxScrollExtent &&
        position.maxScrollExtent < value) {
      return value - position.maxScrollExtent;
    }

    if (!isGoingLeft) {
      return value - position.pixels;
    }
    return 0.0;
  }
}


ListView(

physics: CustomScrollPhysics(),


)
Posted by: Guest on October-28-2021
2

disable scrollview flutter

physics = NeverScrollableScrollPhysics()
Posted by: Guest on May-14-2020
0

how to disable scroll function in flutter

Add this line inside your GridView to disable scrolling

 physics: NeverScrollableScrollPhysics(),
Posted by: Guest on June-10-2021

Code answers related to "disable scrolling flutter"

Browse Popular Code Answers by Language