Skip to content

Commit

Permalink
Revert "Deprecate WhitelistingTextInputFormatter and BlacklistingText…
Browse files Browse the repository at this point in the history
…InputFormatter (flutter#59120)" (flutter#59870)

This reverts commit 8665e13.
  • Loading branch information
christopherfujino authored Jun 19, 2020
1 parent 8665e13 commit 0d7ff7a
Show file tree
Hide file tree
Showing 29 changed files with 158 additions and 662 deletions.
3 changes: 0 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 29,6 @@ analyzer:
missing_return: warning
# allow having TODOs in the code
todo: ignore
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
Expand Down
11 changes: 2 additions & 9 deletions dev/bots/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 135,7 @@ Future<void> run(List<String> arguments) async {
final RegExp _findDeprecationPattern = RegExp(r'@[Dd]eprecated');
final RegExp _deprecationPattern1 = RegExp(r'^( *)@Deprecated\($'); // ignore: flutter_deprecation_syntax (see analyze.dart)
final RegExp _deprecationPattern2 = RegExp(r"^ *'(. ) '$");
final RegExp _deprecationPattern3 = RegExp(r"^ *'This feature was deprecated after v([0-9] )\.([0-9] )\.([0-9] )(\-[0-9] \.[0-9] \.pre)?\.'$");
final RegExp _deprecationPattern3 = RegExp(r"^ *'This feature was deprecated after v([0-9] )\.([0-9] )\.([0-9] )\.'$");
final RegExp _deprecationPattern4 = RegExp(r'^ *\)$');

/// Some deprecation notices are special, for example they're used to annotate members that
Expand Down Expand Up @@ -182,21 182,14 @@ Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches =
if (message == null) {
final String firstChar = String.fromCharCode(match2[1].runes.first);
if (firstChar.toUpperCase() != firstChar)
throw 'Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo';
throw 'Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide.';
}
message = match2[1];
lineNumber = 1;
if (lineNumber >= lines.length)
throw 'Incomplete deprecation notice.';
match3 = _deprecationPattern3.firstMatch(lines[lineNumber]);
} while (match3 == null);
final int v1 = int.parse(match3[1]);
final int v2 = int.parse(match3[2]);
final bool hasV4 = match3[4] != null;
if (v1 > 1 || (v1 == 1 && v2 >= 20)) {
if (!hasV4)
throw 'Deprecation notice does not accurately indicate a dev branch version number; please see https://flutter.dev/docs/development/tools/sdk/releases to find the latest dev build version number.';
}
if (!message.endsWith('.') && !message.endsWith('!') && !message.endsWith('?'))
throw 'Deprecation notice should be a grammatically correct sentence and end with a period.';
if (!lines[lineNumber].startsWith("$indent '"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 55,6 @@ void test10() { }

@Deprecated(
'URLs are not required. '
'This feature was deprecated after v1.0.0.'
'This feature was deprecated after v2.0.0.'
)
void test11() { }

@Deprecated(
'Version number test (should fail). '
'This feature was deprecated after v1.19.0.'
)
void test12() { }

@Deprecated(
'Version number test (should fail). '
'This feature was deprecated after v1.20.0.'
)
void test13() { }

@Deprecated(
'Version number test (should fail). '
'This feature was deprecated after v1.21.0.'
)
void test14() { }

@Deprecated(
'Version number test (should fail). '
'This feature was deprecated after v3.1.0.'
)
void test15() { }

@Deprecated(
'Version number test (should be fine). '
'This feature was deprecated after v0.1.0.'
)
void test16() { }

@Deprecated(
'Version number test (should be fine). '
'This feature was deprecated after v1.20.0-1.0.pre.'
)
void test17() { }
7 changes: 1 addition & 6 deletions dev/bots/test/analyze_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 41,15 @@ void main() {
(
'test/analyze-test-input/root/packages/foo/deprecation.dart:12: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:18: Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: STYLE_GUIDE_URL\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:18: Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:25: Deprecation notice should be a grammatically correct sentence and end with a period.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:29: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:32: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:37: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:48: End of deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:51: Unexpected deprecation notice indent.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:70: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:76: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:82: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
.replaceAll('/', Platform.isWindows ? r'\' : '/')
.replaceAll('STYLE_GUIDE_URL', 'https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo')
.replaceAll('RELEASES_URL', 'https://flutter.dev/docs/development/tools/sdk/releases')
)
'See: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 217,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
validator: _validatePhoneNumber,
// TextInputFormatters are applied in sequence.
inputFormatters: <TextInputFormatter> [
FilteringTextInputFormatter.digitsOnly,
WhitelistingTextInputFormatter.digitsOnly,
// Fit the validating format.
_phoneNumberFormatter,
],
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/cupertino/nav_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 463,7 @@ class _CupertinoNavigationBarState extends State<CupertinoNavigationBar> {
);

final Color actionsForegroundColor = CupertinoDynamicColor.resolve(
widget.actionsForegroundColor,
widget.actionsForegroundColor, // ignore: deprecated_member_use_from_same_package
context,
);
if (!widget.transitionBetweenRoutes || !_isTransitionable(context)) {
Expand Down Expand Up @@ -694,8 694,8 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation
@override
Widget build(BuildContext context) {
// Lint ignore to maintain backward compatibility.
final Color actionsForegroundColor = CupertinoDynamicColor.resolve(widget.actionsForegroundColor, context)
?? CupertinoTheme.of(context).primaryColor;
final Color actionsForegroundColor = CupertinoDynamicColor.resolve(widget.actionsForegroundColor, context) // ignore: deprecated_member_use_from_same_package
?? CupertinoTheme.of(context).primaryColor;

final _NavigationBarStaticComponents components = _NavigationBarStaticComponents(
keys: keys,
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter/lib/src/material/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,11 @@

// @dart = 2.8

// TODO(shihaohong): remove ignoring deprecated member use analysis
// when AlertDialog.scrollable parameter is removed. See
// https://flutter.dev/go/scrollable-alert-dialog for more details.
// ignore_for_file: deprecated_member_use_from_same_package

import 'dart:async';

import 'package:flutter/foundation.dart';
Expand Down
20 changes: 17 additions & 3 deletions packages/flutter/lib/src/material/input_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 1927,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat

final bool labelIsInitiallyFloating = widget.decoration.floatingLabelBehavior == FloatingLabelBehavior.always
|| (widget.decoration.floatingLabelBehavior != FloatingLabelBehavior.never &&
// ignore: deprecated_member_use_from_same_package
widget.decoration.hasFloatingPlaceholder &&
widget._labelShouldWithdraw);

Expand Down Expand Up @@ -1975,6 1976,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
bool get isHovering => widget.isHovering && decoration.enabled;
bool get isEmpty => widget.isEmpty;
bool get _floatingLabelEnabled {
// ignore: deprecated_member_use_from_same_package
return decoration.hasFloatingPlaceholder && decoration.floatingLabelBehavior != FloatingLabelBehavior.never;
}

Expand All @@ -1985,6 1987,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
_effectiveDecoration = null;

final bool floatBehaviorChanged = widget.decoration.floatingLabelBehavior != old.decoration.floatingLabelBehavior
// ignore: deprecated_member_use_from_same_package
|| widget.decoration.hasFloatingPlaceholder != old.decoration.hasFloatingPlaceholder;

if (widget._labelShouldWithdraw != old._labelShouldWithdraw || floatBehaviorChanged) {
Expand Down Expand Up @@ -2517,7 2520,7 @@ class InputDecoration {
'Use floatingLabelBehavior instead. '
'This feature was deprecated after v1.13.2.'
)
this.hasFloatingPlaceholder = true,
this.hasFloatingPlaceholder = true, // ignore: deprecated_member_use_from_same_package
this.floatingLabelBehavior = FloatingLabelBehavior.auto,
this.isCollapsed = false,
this.isDense,
Expand Down Expand Up @@ -2563,6 2566,7 @@ class InputDecoration {
'Use floatingLabelBehavior instead. '
'This feature was deprecated after v1.13.2.'
)
// ignore: deprecated_member_use_from_same_package
this.hasFloatingPlaceholder = true,
this.floatingLabelBehavior = FloatingLabelBehavior.auto,
this.hintStyle,
Expand All @@ -2573,8 2577,9 @@ class InputDecoration {
this.border = InputBorder.none,
this.enabled = true,
}) : assert(enabled != null),
// ignore: deprecated_member_use_from_same_package
assert(!(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)),
'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always'),
'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always'),
icon = null,
labelText = null,
labelStyle = null,
Expand Down Expand Up @@ -3367,6 3372,7 @@ class InputDecoration {
errorText: errorText ?? this.errorText,
errorStyle: errorStyle ?? this.errorStyle,
errorMaxLines: errorMaxLines ?? this.errorMaxLines,
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder: hasFloatingPlaceholder ?? this.hasFloatingPlaceholder,
floatingLabelBehavior: floatingLabelBehavior ?? this.floatingLabelBehavior,
isCollapsed: isCollapsed ?? this.isCollapsed,
Expand Down Expand Up @@ -3414,6 3420,7 @@ class InputDecoration {
hintStyle: hintStyle ?? theme.hintStyle,
errorStyle: errorStyle ?? theme.errorStyle,
errorMaxLines: errorMaxLines ?? theme.errorMaxLines,
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder: hasFloatingPlaceholder ?? theme.hasFloatingPlaceholder,
floatingLabelBehavior: floatingLabelBehavior ?? theme.floatingLabelBehavior,
isCollapsed: isCollapsed ?? theme.isCollapsed,
Expand Down Expand Up @@ -3455,6 3462,7 @@ class InputDecoration {
&& other.errorText == errorText
&& other.errorStyle == errorStyle
&& other.errorMaxLines == errorMaxLines
// ignore: deprecated_member_use_from_same_package
&& other.hasFloatingPlaceholder == hasFloatingPlaceholder
&& other.floatingLabelBehavior == floatingLabelBehavior
&& other.isDense == isDense
Expand Down Expand Up @@ -3503,7 3511,7 @@ class InputDecoration {
errorText,
errorStyle,
errorMaxLines,
hasFloatingPlaceholder,
hasFloatingPlaceholder,// ignore: deprecated_member_use_from_same_package
floatingLabelBehavior,
isDense,
contentPadding,
Expand Down Expand Up @@ -3552,6 3560,7 @@ class InputDecoration {
if (errorText != null) 'errorText: "$errorText"',
if (errorStyle != null) 'errorStyle: "$errorStyle"',
if (errorMaxLines != null) 'errorMaxLines: "$errorMaxLines"',
// ignore: deprecated_member_use_from_same_package
if (hasFloatingPlaceholder == false) 'hasFloatingPlaceholder: false',
if (floatingLabelBehavior != null) 'floatingLabelBehavior: $floatingLabelBehavior',
if (isDense ?? false) 'isDense: $isDense',
Expand Down Expand Up @@ -3615,6 3624,7 @@ class InputDecorationTheme with Diagnosticable {
'Use floatingLabelBehavior instead. '
'This feature was deprecated after v1.13.2.'
)
// ignore: deprecated_member_use_from_same_package
this.hasFloatingPlaceholder = true,
this.floatingLabelBehavior = FloatingLabelBehavior.auto,
this.isDense = false,
Expand All @@ -3638,6 3648,7 @@ class InputDecorationTheme with Diagnosticable {
assert(isCollapsed != null),
assert(filled != null),
assert(alignLabelWithHint != null),
// ignore: deprecated_member_use_from_same_package
assert(!(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)),
'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always');

Expand Down Expand Up @@ -3990,6 4001,7 @@ class InputDecorationTheme with Diagnosticable {
hintStyle: hintStyle ?? this.hintStyle,
errorStyle: errorStyle ?? this.errorStyle,
errorMaxLines: errorMaxLines ?? this.errorMaxLines,
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder: hasFloatingPlaceholder ?? this.hasFloatingPlaceholder,
floatingLabelBehavior: floatingLabelBehavior ?? this.floatingLabelBehavior,
isDense: isDense ?? this.isDense,
Expand Down Expand Up @@ -4021,6 4033,7 @@ class InputDecorationTheme with Diagnosticable {
hintStyle,
errorStyle,
errorMaxLines,
// ignore: deprecated_member_use_from_same_package
hasFloatingPlaceholder,
floatingLabelBehavior,
isDense,
Expand Down Expand Up @@ -4087,6 4100,7 @@ class InputDecorationTheme with Diagnosticable {
properties.add(DiagnosticsProperty<TextStyle>('hintStyle', hintStyle, defaultValue: defaultTheme.hintStyle));
properties.add(DiagnosticsProperty<TextStyle>('errorStyle', errorStyle, defaultValue: defaultTheme.errorStyle));
properties.add(IntProperty('errorMaxLines', errorMaxLines, defaultValue: defaultTheme.errorMaxLines));
// ignore: deprecated_member_use_from_same_package
properties.add(DiagnosticsProperty<bool>('hasFloatingPlaceholder', hasFloatingPlaceholder, defaultValue: defaultTheme.hasFloatingPlaceholder));
properties.add(DiagnosticsProperty<FloatingLabelBehavior>('floatingLabelBehavior', floatingLabelBehavior, defaultValue: defaultTheme.floatingLabelBehavior));
properties.add(DiagnosticsProperty<bool>('isDense', isDense, defaultValue: defaultTheme.isDense));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 29,9 @@ const double _maxCalendarWidthPortrait = 480.0;

/// Displays a scrollable calendar grid that allows a user to select a range
/// of dates.
//
// This is not publicly exported (see pickers.dart), as it is an
// internal component used by [showDateRangePicker].
///
/// Note: this is not publicly exported (see pickers.dart), as it is an
/// internal component used by [showDateRangePicker].
class CalendarDateRangePicker extends StatefulWidget {
/// Creates a scrollable calendar grid for picking date ranges.
CalendarDateRangePicker({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@ import '../theme.dart';

import 'date_picker_common.dart';

// This is the original implementation for the Material Date Picker.
// NOTE: this is the original implementation for the Material Date Picker.
// These classes are deprecated and the whole file can be removed after
// this has been on stable for long enough for people to migrate to the new
// CalendarDatePicker (if needed, as showDatePicker has already been migrated
Expand Down Expand Up @@ -406,6 406,7 @@ class MonthPicker extends StatefulWidget {
_MonthPickerState createState() => _MonthPickerState();
}

// ignore: deprecated_member_use_from_same_package
class _MonthPickerState extends State<MonthPicker> with SingleTickerProviderStateMixin {
static final Animatable<double> _chevronOpacityTween = Tween<double>(begin: 1.0, end: 0.0)
.chain(CurveTween(curve: Curves.easeInOut));
Expand All @@ -427,6 428,7 @@ class _MonthPickerState extends State<MonthPicker> with SingleTickerProviderStat
}

@override
// ignore: deprecated_member_use_from_same_package
void didUpdateWidget(MonthPicker oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.selectedDate != oldWidget.selectedDate) {
Expand Down Expand Up @@ -477,6 479,7 @@ class _MonthPickerState extends State<MonthPicker> with SingleTickerProviderStat

Widget _buildItems(BuildContext context, int index) {
final DateTime month = _addMonthsToMonthDate(widget.firstDate, index);
// ignore: deprecated_member_use_from_same_package
return DayPicker(
key: ValueKey<DateTime>(month),
selectedDate: widget.selectedDate,
Expand Down Expand Up @@ -672,6 675,7 @@ class YearPicker extends StatefulWidget {
_YearPickerState createState() => _YearPickerState();
}

// ignore: deprecated_member_use_from_same_package
class _YearPickerState extends State<YearPicker> {
static const double _itemExtent = 50.0;
ScrollController scrollController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ import '../material.dart';
import '../text_theme.dart';
import '../theme.dart';

// This is an internal implementation file. Even though there are public
// NOTE: This is an internal implementation file. Even though there are public
// classes and functions defined here, they are only meant to be used by the
// date picker implementation and are not exported as part of the Material library.
// See pickers.dart for exactly what is considered part of the public API.
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/lib/src/material/pickers/date_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 4,10 @@

// @dart = 2.8


// Common date utility functions used by the date picker implementation

// This is an internal implementation file. Even though there are public
// NOTE: This is an internal implementation file. Even though there are public
// classes and functions defined here, they are only meant to be used by the
// date picker implementation and are not exported as part of the Material library.
// See pickers.dart for exactly what is considered part of the public API.
Expand Down
Loading

0 comments on commit 0d7ff7a

Please sign in to comment.