diff --git a/packages/flutter/lib/fix_data/fix_material/fix_input_decoration.yaml b/packages/flutter/lib/fix_data/fix_material/fix_input_decoration.yaml new file mode 100644 index 0000000000..e70bd02613 --- /dev/null +++ b/packages/flutter/lib/fix_data/fix_material/fix_input_decoration.yaml @@ -0,0 +1,245 @@ +# 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/to/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 InputDecoration and InputDecorationTheme from the Material library. * +version: 1 +transforms: + # Changes made in https://github.com/flutter/flutter/pull/152486. + - title: "Remove invalid parameter" + date: 2024-07-27 + element: + uris: [ 'material.dart' ] + constructor: 'collapsed' + inClass: 'InputDecoration' + changes: + - kind: 'removeParameter' + name: 'floatingLabelBehavior' + + # Changes made in https://github.com/flutter/flutter/pull/152486. + - title: "Remove invalid parameter" + date: 2024-07-27 + element: + uris: [ 'material.dart' ] + constructor: 'collapsed' + inClass: 'InputDecoration' + changes: + - kind: 'removeParameter' + name: 'floatingLabelAlignment' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Migrate to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + field: 'hasFloatingPlaceholder' + inClass: 'InputDecorationTheme' + changes: + - kind: 'rename' + newName: 'floatingLabelBehavior' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Migrate to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + constructor: '' + inClass: 'InputDecorationTheme' + oneOf: + - if: "hasFloatingPlaceholder == 'true'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.auto' + requiredIf: "hasFloatingPlaceholder == 'true'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + - if: "hasFloatingPlaceholder == 'false'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.never' + requiredIf: "hasFloatingPlaceholder == 'false'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + variables: + hasFloatingPlaceholder: + kind: 'fragment' + value: 'arguments[hasFloatingPlaceholder]' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Migrate to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + method: 'copyWith' + inClass: 'InputDecorationTheme' + oneOf: + - if: "hasFloatingPlaceholder == 'true'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.auto' + requiredIf: "hasFloatingPlaceholder == 'true'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + - if: "hasFloatingPlaceholder == 'false'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.never' + requiredIf: "hasFloatingPlaceholder == 'false'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + variables: + hasFloatingPlaceholder: + kind: 'fragment' + value: 'arguments[hasFloatingPlaceholder]' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Migrate to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + field: 'hasFloatingPlaceholder' + inClass: 'InputDecoration' + changes: + - kind: 'rename' + newName: 'floatingLabelBehavior' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Rename to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + constructor: 'collapsed' + inClass: 'InputDecoration' + oneOf: + - if: "hasFloatingPlaceholder == 'true'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.auto' + requiredIf: "hasFloatingPlaceholder == 'true'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + - if: "hasFloatingPlaceholder == 'false'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.never' + requiredIf: "hasFloatingPlaceholder == 'false'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + variables: + hasFloatingPlaceholder: + kind: 'fragment' + value: 'arguments[hasFloatingPlaceholder]' + + # Changes made in https://github.com/flutter/flutter/pull/46115 + - title: "Rename to 'floatingLabelBehavior'" + date: 2020-01-15 + element: + uris: [ 'material.dart' ] + constructor: '' + inClass: 'InputDecoration' + oneOf: + - if: "hasFloatingPlaceholder == 'true'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.auto' + requiredIf: "hasFloatingPlaceholder == 'true'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + - if: "hasFloatingPlaceholder == 'false'" + changes: + - kind: 'addParameter' + index: 14 + name: 'floatingLabelBehavior' + style: optional_named + argumentValue: + expression: '{% FloatingLabelBehavior %}.never' + requiredIf: "hasFloatingPlaceholder == 'false'" + variables: + FloatingLabelBehavior: + kind: 'import' + uris: [ 'material.dart' ] + name: 'FloatingLabelBehavior' + - kind: 'removeParameter' + name: 'hasFloatingPlaceholder' + variables: + hasFloatingPlaceholder: + kind: 'fragment' + value: 'arguments[hasFloatingPlaceholder]' + +# Before adding a new fix: read instructions at the top of this file. diff --git a/packages/flutter/lib/fix_data/fix_material/fix_material.yaml b/packages/flutter/lib/fix_data/fix_material/fix_material.yaml index f395190fcf..e284d006f9 100644 --- a/packages/flutter/lib/fix_data/fix_material/fix_material.yaml +++ b/packages/flutter/lib/fix_data/fix_material/fix_material.yaml @@ -289,208 +289,6 @@ transforms: - kind: 'removeParameter' name: 'disabledThumbGapWidth' - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Migrate to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - field: 'hasFloatingPlaceholder' - inClass: 'InputDecorationTheme' - changes: - - kind: 'rename' - newName: 'floatingLabelBehavior' - - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Migrate to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - constructor: '' - inClass: 'InputDecorationTheme' - oneOf: - - if: "hasFloatingPlaceholder == 'true'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.auto' - requiredIf: "hasFloatingPlaceholder == 'true'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - - if: "hasFloatingPlaceholder == 'false'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.never' - requiredIf: "hasFloatingPlaceholder == 'false'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - variables: - hasFloatingPlaceholder: - kind: 'fragment' - value: 'arguments[hasFloatingPlaceholder]' - - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Migrate to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - method: 'copyWith' - inClass: 'InputDecorationTheme' - oneOf: - - if: "hasFloatingPlaceholder == 'true'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.auto' - requiredIf: "hasFloatingPlaceholder == 'true'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - - if: "hasFloatingPlaceholder == 'false'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.never' - requiredIf: "hasFloatingPlaceholder == 'false'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - variables: - hasFloatingPlaceholder: - kind: 'fragment' - value: 'arguments[hasFloatingPlaceholder]' - - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Migrate to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - field: 'hasFloatingPlaceholder' - inClass: 'InputDecoration' - changes: - - kind: 'rename' - newName: 'floatingLabelBehavior' - - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Rename to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - constructor: 'collapsed' - inClass: 'InputDecoration' - oneOf: - - if: "hasFloatingPlaceholder == 'true'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.auto' - requiredIf: "hasFloatingPlaceholder == 'true'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - - if: "hasFloatingPlaceholder == 'false'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.never' - requiredIf: "hasFloatingPlaceholder == 'false'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - variables: - hasFloatingPlaceholder: - kind: 'fragment' - value: 'arguments[hasFloatingPlaceholder]' - - # Changes made in https://github.com/flutter/flutter/pull/46115 - - title: "Rename to 'floatingLabelBehavior'" - date: 2020-01-15 - element: - uris: [ 'material.dart' ] - constructor: '' - inClass: 'InputDecoration' - oneOf: - - if: "hasFloatingPlaceholder == 'true'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.auto' - requiredIf: "hasFloatingPlaceholder == 'true'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - - if: "hasFloatingPlaceholder == 'false'" - changes: - - kind: 'addParameter' - index: 14 - name: 'floatingLabelBehavior' - style: optional_named - argumentValue: - expression: '{% FloatingLabelBehavior %}.never' - requiredIf: "hasFloatingPlaceholder == 'false'" - variables: - FloatingLabelBehavior: - kind: 'import' - uris: [ 'material.dart' ] - name: 'FloatingLabelBehavior' - - kind: 'removeParameter' - name: 'hasFloatingPlaceholder' - variables: - hasFloatingPlaceholder: - kind: 'fragment' - value: 'arguments[hasFloatingPlaceholder]' - # Changes made in https://github.com/flutter/flutter/pull/96115 - title: "Migrate 'Icons.pie_chart_outlined' to 'Icons.pie_chart_outline'" date: 2022-01-04 diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index ab8660e6bf..3e59a192e3 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -2629,8 +2629,16 @@ class InputDecoration { /// Sets the [contentPadding] property to [EdgeInsets.zero]. const InputDecoration.collapsed({ required this.hintText, - this.floatingLabelBehavior, - this.floatingLabelAlignment, + @Deprecated( + 'Invalid parameter because a collapsed decoration has no label. ' + 'This feature was deprecated after v3.24.0-0.1.pre.', + ) + FloatingLabelBehavior? floatingLabelBehavior, + @Deprecated( + 'Invalid parameter because a collapsed decoration has no label. ' + 'This feature was deprecated after v3.24.0-0.1.pre.', + ) + FloatingLabelAlignment? floatingLabelAlignment, this.hintStyle, this.hintTextDirection, this.hintMaxLines, @@ -2680,6 +2688,10 @@ class InputDecoration { disabledBorder = null, enabledBorder = null, semanticCounterText = null, + // ignore: prefer_initializing_formals, (can't use initializing formals for a deprecated parameter). + floatingLabelBehavior = floatingLabelBehavior, + // ignore: prefer_initializing_formals, (can't use initializing formals for a deprecated parameter). + floatingLabelAlignment = floatingLabelAlignment, alignLabelWithHint = false; /// An icon to show before the input field and outside of the decoration's diff --git a/packages/flutter/test_fixes/material/input_decorator.dart b/packages/flutter/test_fixes/material/input_decorator.dart new file mode 100644 index 0000000000..a3f68ec989 --- /dev/null +++ b/packages/flutter/test_fixes/material/input_decorator.dart @@ -0,0 +1,34 @@ +// 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/material.dart'; + +void main() { + // Changes made in https://github.com/flutter/flutter/pull/46115. + const InputDecoration inputDecoration = InputDecoration(hasFloatingPlaceholder: true); + InputDecoration(hasFloatingPlaceholder: false); + InputDecoration(); + InputDecoration(error: ''); + InputDecoration.collapsed(hasFloatingPlaceholder: true); + InputDecoration.collapsed(hasFloatingPlaceholder: false); + InputDecoration.collapsed(); + InputDecoration.collapsed(error: ''); + inputDecoration.hasFloatingPlaceholder; + const InputDecorationTheme inputDecorationTheme = InputDecorationTheme(hasFloatingPlaceholder: true); + InputDecorationTheme(hasFloatingPlaceholder: false); + InputDecorationTheme(); + InputDecorationTheme(error: ''); + inputDecorationTheme.hasFloatingPlaceholder; + inputDecorationTheme.copyWith(hasFloatingPlaceholder: false); + inputDecorationTheme.copyWith(hasFloatingPlaceholder: true); + inputDecorationTheme.copyWith(); + inputDecorationTheme.copyWith(error: ''); + + // Changes made in https://github.com/flutter/flutter/pull/152486. + const InputDecoration decoration = InputDecoration.collapsed( + hintText: 'Hint', + floatingLabelAlignment: FloatingLabelAlignment.center, + floatingLabelBehavior: FloatingLabelBehavior.always, + ); +} diff --git a/packages/flutter/test_fixes/material/input_decorator.dart.expect b/packages/flutter/test_fixes/material/input_decorator.dart.expect new file mode 100644 index 0000000000..4b1fdff912 --- /dev/null +++ b/packages/flutter/test_fixes/material/input_decorator.dart.expect @@ -0,0 +1,32 @@ +// 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/material.dart'; + +void main() { + // Changes made in https://github.com/flutter/flutter/pull/46115. + const InputDecoration inputDecoration = InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.auto); + InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.never); + InputDecoration(); + InputDecoration(error: ''); + InputDecoration.collapsed(); + InputDecoration.collapsed(); + InputDecoration.collapsed(); + InputDecoration.collapsed(error: ''); + inputDecoration.floatingLabelBehavior; + const InputDecorationTheme inputDecorationTheme = InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.auto); + InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.never); + InputDecorationTheme(); + InputDecorationTheme(error: ''); + inputDecorationTheme.floatingLabelBehavior; + inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.never); + inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.auto); + inputDecorationTheme.copyWith(); + inputDecorationTheme.copyWith(error: ''); + + // Changes made in https://github.com/flutter/flutter/pull/152486. + const InputDecoration decoration = InputDecoration.collapsed( + hintText: 'Hint', + ); +} diff --git a/packages/flutter/test_fixes/material/material.dart b/packages/flutter/test_fixes/material/material.dart index 60cec7b432..41938f6c16 100644 --- a/packages/flutter/test_fixes/material/material.dart +++ b/packages/flutter/test_fixes/material/material.dart @@ -163,26 +163,6 @@ void main() { RectangularSliderTrackShape(disabledThumbGapWidth: 2.0); RectangularSliderTrackShape(error: ''); - // Changes made in https://github.com/flutter/flutter/pull/46115 - const InputDecoration inputDecoration = InputDecoration(hasFloatingPlaceholder: true); - InputDecoration(hasFloatingPlaceholder: false); - InputDecoration(); - InputDecoration(error: ''); - InputDecoration.collapsed(hasFloatingPlaceholder: true); - InputDecoration.collapsed(hasFloatingPlaceholder: false); - InputDecoration.collapsed(); - InputDecoration.collapsed(error: ''); - inputDecoration.hasFloatingPlaceholder; - const InputDecorationTheme inputDecorationTheme = InputDecorationTheme(hasFloatingPlaceholder: true); - InputDecorationTheme(hasFloatingPlaceholder: false); - InputDecorationTheme(); - InputDecorationTheme(error: ''); - inputDecorationTheme.hasFloatingPlaceholder; - inputDecorationTheme.copyWith(hasFloatingPlaceholder: false); - inputDecorationTheme.copyWith(hasFloatingPlaceholder: true); - inputDecorationTheme.copyWith(); - inputDecorationTheme.copyWith(error: ''); - // Changes made in https://github.com/flutter/flutter/pull/79160 Draggable draggable = Draggable(); draggable = Draggable(dragAnchor: DragAnchor.child); diff --git a/packages/flutter/test_fixes/material/material.dart.expect b/packages/flutter/test_fixes/material/material.dart.expect index 4fe9559869..512a8198bb 100644 --- a/packages/flutter/test_fixes/material/material.dart.expect +++ b/packages/flutter/test_fixes/material/material.dart.expect @@ -163,26 +163,6 @@ void main() { RectangularSliderTrackShape(); RectangularSliderTrackShape(error: ''); - // Changes made in https://github.com/flutter/flutter/pull/46115 - const InputDecoration inputDecoration = InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.auto); - InputDecoration(floatingLabelBehavior: FloatingLabelBehavior.never); - InputDecoration(); - InputDecoration(error: ''); - InputDecoration.collapsed(floatingLabelBehavior: FloatingLabelBehavior.auto); - InputDecoration.collapsed(floatingLabelBehavior: FloatingLabelBehavior.never); - InputDecoration.collapsed(); - InputDecoration.collapsed(error: ''); - inputDecoration.floatingLabelBehavior; - const InputDecorationTheme inputDecorationTheme = InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.auto); - InputDecorationTheme(floatingLabelBehavior: FloatingLabelBehavior.never); - InputDecorationTheme(); - InputDecorationTheme(error: ''); - inputDecorationTheme.floatingLabelBehavior; - inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.never); - inputDecorationTheme.copyWith(floatingLabelBehavior: FloatingLabelBehavior.auto); - inputDecorationTheme.copyWith(); - inputDecorationTheme.copyWith(error: ''); - // Changes made in https://github.com/flutter/flutter/pull/79160 Draggable draggable = Draggable(); draggable = Draggable(dragAnchorStrategy: childDragAnchorStrategy);