Skip to content

Commit

Permalink
Remove deprecated InteractiveViewer.alignPanAxis (flutter#142500)
Browse files Browse the repository at this point in the history
  • Loading branch information
LongCatIsLooong committed Feb 23, 2024
1 parent 59da873 commit fcd154b
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 29 deletions.
105 changes: 105 additions & 0 deletions packages/flutter/lib/fix_data/fix_widgets/fix_interactive_viewer.yaml
@@ -0,0 +1,105 @@
# Copyright 2014 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# For details regarding the *Flutter Fix* feature, see
# https://flutter.dev/docs/development/tools/flutter-fix

# Please add new fixes to the top of the file, separated by one blank line
# from other fixes. In a comment, include a link to the PR where the change
# requiring the fix was made.

# Every fix must be tested. See the flutter/packages/flutter/test_fixes/README.md
# file for instructions on testing these data driven fixes.

# For documentation about this file format, see
# https://dart.dev/go/data-driven-fixes.

# * Fixes in this file are for InteractiveViewer from the widgets library. *
version: 1
transforms:
# Change made in https://github.com/flutter/flutter/pull/109014
- title: "Migrate to 'panAxis'"
date: 2024-02-22
element:
uris: [ 'widgets.dart', 'material.dart', 'cupertino.dart' ]
constructor: ''
inClass: 'InteractiveViewer'
variables:
alignPanAxis:
kind: 'fragment'
value: 'arguments[alignPanAxis]'
panAxis:
kind: 'fragment'
value: 'arguments[panAxis]'
oneOf:
- if: "panAxis == '' && alignPanAxis == 'true'"
changes:
- kind: 'addParameter'
index: 0
name: 'panAxis'
style: optional_named
argumentValue:
expression: 'PanAxis.aligned'
requiredIf: "alignPanAxis == 'true'"
- kind: 'removeParameter'
name: 'alignPanAxis'
- if: "panAxis == '' && alignPanAxis == 'false'"
changes:
- kind: 'addParameter'
index: 0
name: 'panAxis'
style: optional_named
argumentValue:
expression: 'PanAxis.free'
requiredIf: "alignPanAxis == 'false'"
- kind: 'removeParameter'
name: 'alignPanAxis'
- if: "alignPanAxis != ''"
changes:
- kind: 'removeParameter'
name: 'alignPanAxis'

# Change made in https://github.com/flutter/flutter/pull/109014
- title: "Migrate to 'panAxis'"
date: 2024-02-22
element:
uris: [ 'widgets.dart', 'material.dart', 'cupertino.dart' ]
constructor: 'builder'
inClass: 'InteractiveViewer'
variables:
alignPanAxis:
kind: 'fragment'
value: 'arguments[alignPanAxis]'
panAxis:
kind: 'fragment'
value: 'arguments[panAxis]'
oneOf:
- if: "panAxis == '' && alignPanAxis == 'true'"
changes:
- kind: 'addParameter'
index: 0
name: 'panAxis'
style: optional_named
argumentValue:
expression: 'PanAxis.aligned'
requiredIf: "alignPanAxis == 'true'"
- kind: 'removeParameter'
name: 'alignPanAxis'
- if: "panAxis == '' && alignPanAxis == 'false'"
changes:
- kind: 'addParameter'
index: 0
name: 'panAxis'
style: optional_named
argumentValue:
expression: 'PanAxis.free'
requiredIf: "alignPanAxis == 'false'"
- kind: 'removeParameter'
name: 'alignPanAxis'
- if: "alignPanAxis != ''"
changes:
- kind: 'removeParameter'
name: 'alignPanAxis'

# Before adding a new fix: read instructions at the top of this file.
29 changes: 0 additions & 29 deletions packages/flutter/lib/src/widgets/interactive_viewer.dart
Expand Up @@ -63,11 +63,6 @@ class InteractiveViewer extends StatefulWidget {
InteractiveViewer({
super.key,
this.clipBehavior = Clip.hardEdge,
@Deprecated(
'Use panAxis instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
this.alignPanAxis = false,
this.panAxis = PanAxis.free,
this.boundaryMargin = EdgeInsets.zero,
this.constrained = true,
Expand Down Expand Up @@ -112,11 +107,6 @@ class InteractiveViewer extends StatefulWidget {
InteractiveViewer.builder({
super.key,
this.clipBehavior = Clip.hardEdge,
@Deprecated(
'Use panAxis instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
this.alignPanAxis = false,
this.panAxis = PanAxis.free,
this.boundaryMargin = EdgeInsets.zero,
// These default scale values were eyeballed as reasonable limits for common
Expand Down Expand Up @@ -162,25 +152,6 @@ class InteractiveViewer extends StatefulWidget {
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;

/// This property is deprecated, please use [panAxis] instead.
///
/// If true, panning is only allowed in the direction of the horizontal axis
/// or the vertical axis.
///
/// In other words, when this is true, diagonal panning is not allowed. A
/// single gesture begun along one axis cannot also cause panning along the
/// other axis without stopping and beginning a new gesture. This is a common
/// pattern in tables where data is displayed in columns and rows.
///
/// See also:
/// * [constrained], which has an example of creating a table that uses
/// alignPanAxis.
@Deprecated(
'Use panAxis instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
final bool alignPanAxis;

/// When set to [PanAxis.aligned], panning is only allowed in the horizontal
/// axis or the vertical axis, diagonal panning is not allowed.
///
Expand Down
20 changes: 20 additions & 0 deletions packages/flutter/test_fixes/widgets/interactive_viewer.dart
@@ -0,0 +1,20 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';

void main() {
// Change made in https://github.com/flutter/flutter/pull/109014
InteractiveViewer(alignPanAxis: false);
InteractiveViewer.builder(alignPanAxis: false);

InteractiveViewer(alignPanAxis: true);
InteractiveViewer.builder(alignPanAxis: true);

InteractiveViewer(alignPanAxis: false, panAxis: PanAxis.aligned,);
InteractiveViewer.builder(alignPanAxis: false, panAxis: PanAxis.aligned,);

InteractiveViewer(alignPanAxis: true, panAxis: PanAxis.aligned,);
InteractiveViewer.builder(alignPanAxis: true, panAxis: PanAxis.aligned,);
}
20 changes: 20 additions & 0 deletions packages/flutter/test_fixes/widgets/interactive_viewer.dart.expect
@@ -0,0 +1,20 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';

void main() {
// Change made in https://github.com/flutter/flutter/pull/109014
InteractiveViewer(panAxis: PanAxis.free);
InteractiveViewer.builder(panAxis: PanAxis.free);

InteractiveViewer(panAxis: PanAxis.aligned);
InteractiveViewer.builder(panAxis: PanAxis.aligned);

InteractiveViewer(panAxis: PanAxis.aligned,);
InteractiveViewer.builder(panAxis: PanAxis.aligned,);

InteractiveViewer(panAxis: PanAxis.aligned,);
InteractiveViewer.builder(panAxis: PanAxis.aligned,);
}

0 comments on commit fcd154b

Please sign in to comment.