Draggable can be accepted when the data is null (#97355)

This commit is contained in:
xubaolin
2022-02-24 07:19:22 +08:00
committed by GitHub
parent 9e7cc970ea
commit 2ad0ac0ef2
4 changed files with 130 additions and 37 deletions

View File

@@ -16,9 +16,9 @@ class ExampleDragTarget extends StatefulWidget {
class ExampleDragTargetState extends State<ExampleDragTarget> {
Color _color = Colors.grey;
void _handleAccept(Color data) {
void _handleAccept(Color? data) {
setState(() {
_color = data;
_color = data!;
});
}
@@ -215,7 +215,7 @@ class MovableBall extends StatelessWidget {
);
} else {
return DragTarget<bool>(
onAccept: (bool data) { callback(position); },
onAccept: (bool? data) { callback(position); },
builder: (BuildContext context, List<bool?> accepted, List<dynamic> rejected) {
return dashedBall;
},