Deprecates onWillAccept and onAccept callbacks in DragTarget. (#133691)

This PR deprecates `onWillAccept` and `onAccept` over `onWillAcceptWithDetails` and `onAcceptWithDetails`.

Fixes: #133347
This commit is contained in:
Chinmoy
2023-11-11 04:17:22 +05:30
committed by GitHub
parent d71fe92ec4
commit 0bde95dc06
10 changed files with 174 additions and 6 deletions

View File

@@ -0,0 +1,46 @@
# 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 DragTarget from the Widgets library. *
version: 1
transforms:
# Changes made in https://github.com/flutter/flutter/pull/133691
- title: "Migrate 'onWillAccept' to 'onWillAcceptWithDetails'"
date: 2023-08-30
element:
uris: [ 'widgets.dart', 'material.dart', 'cupertino.dart' ]
constructor: ''
inClass: 'DragTarget'
changes:
- kind: 'renameParameter'
oldName: 'onWillAccept'
newName: 'onWillAcceptWithDetails'
# Changes made in https://github.com/flutter/flutter/pull/133691
- title: "Migrate 'onAccept' to 'onAcceptWithDetails'"
date: 2023-08-30
element:
uris: [ 'widgets.dart', 'material.dart', 'cupertino.dart' ]
constructor: ''
inClass: 'DragTarget'
changes:
- kind: 'renameParameter'
oldName: 'onAccept'
newName: 'onAcceptWithDetails'
# Before adding a new fix: read instructions at the top of this file.

View File

@@ -611,8 +611,18 @@ class DragTarget<T extends Object> extends StatefulWidget {
const DragTarget({
super.key,
required this.builder,
@Deprecated(
'Use onWillAcceptWithDetails instead. '
'This callback is similar to onWillAcceptWithDetails but does not provide drag details. '
'This feature was deprecated after v3.14.0-0.2.pre.'
)
this.onWillAccept,
this.onWillAcceptWithDetails,
@Deprecated(
'Use onAcceptWithDetails instead. '
'This callback is similar to onAcceptWithDetails but does not provide drag details. '
'This feature was deprecated after v3.14.0-0.2.pre.'
)
this.onAccept,
this.onAcceptWithDetails,
this.onLeave,
@@ -636,6 +646,11 @@ class DragTarget<T extends Object> extends StatefulWidget {
/// Equivalent to [onWillAcceptWithDetails], but only includes the data.
///
/// Must not be provided if [onWillAcceptWithDetails] is provided.
@Deprecated(
'Use onWillAcceptWithDetails instead. '
'This callback is similar to onWillAcceptWithDetails but does not provide drag details. '
'This feature was deprecated after v3.14.0-0.2.pre.'
)
final DragTargetWillAccept<T>? onWillAccept;
/// Called to determine whether this widget is interested in receiving a given
@@ -655,6 +670,11 @@ class DragTarget<T extends Object> extends StatefulWidget {
/// It will not be called if `data` is `null`.
///
/// Equivalent to [onAcceptWithDetails], but only includes the data.
@Deprecated(
'Use onAcceptWithDetails instead. '
'This callback is similar to onAcceptWithDetails but does not provide drag details. '
'This feature was deprecated after v3.14.0-0.2.pre.'
)
final DragTargetAccept<T>? onAccept;
/// Called when an acceptable piece of data was dropped over this drag target.

View File

@@ -0,0 +1,17 @@
// 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/cupertino.dart';
void main() {
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAccept: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAccept: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}

View File

@@ -0,0 +1,17 @@
// 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/cupertino.dart';
void main() {
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}

View File

@@ -0,0 +1,17 @@
// 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/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAccept: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAccept: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}

View File

@@ -0,0 +1,17 @@
// 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/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}

View File

@@ -0,0 +1,17 @@
// 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() {
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAccept: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAccept: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}

View File

@@ -0,0 +1,17 @@
// 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() {
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onWillAcceptWithDetails: (data) => ());
// Changes made in https://github.com/flutter/flutter/pull/133691
const dragTarget = DragTarget();
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
dragTarget = DragTarget(onAcceptWithDetails: (data) => ());
}