I wrote a custom code for a drag and drop action. But it is not working since it shows the error that the custom action cannot be parsed.

// Automatic FlutterFlow imports

import '/flutter_flow/flutter_flow_theme.dart';

import '/flutter_flow/flutter_flow_util.dart';

import '/custom_code/actions/index.dart'; // Imports other custom actions

import '/flutter_flow/custom_functions.dart'; // Imports custom functions

import 'package:flutter/material.dart';

// Begin custom action code

// DO NOT REMOVE OR MODIFY THE CODE ABOVE!


Future test(){

class MyDraggableWidget extends StatefulWidget {

@override

MyDraggableWidgetState createState() => MyDraggableWidgetState();

}


class _MyDraggableWidgetState extends State<MyDraggableWidget> {

// Define the source and destination columns

late Column sourceColumn;

late Column destinationColumn;


@override

void initState() {

super.initState();


sourceColumn = Column(

children: [

// Add widgets to the source column

// For example: Text('Drag me'),

],

);


destinationColumn = Column(

children: [

// Add widgets to the destination column

],

);

}


// Function to convert data to a widget

Widget _convertToWidget(dynamic data) {

// Replace this with your actual conversion logic

// For example, if your data is a String, you can create a Text widget

if (data is String) {

return Text(data);

} else {

return Container(); // Return an empty container as a fallback

}

}


@override

Widget build(BuildContext context) {

// Create a DragTarget widget to receive the dragged item

final dragTarget = DragTarget(

builder: (BuildContext context, List<dynamic> candidateData,

List<dynamic> rejectedData) {

return destinationColumn;

},

onWillAccept: (data) {

// Check if the data being dragged is acceptable

return true;

},

onAccept: (data) {

// Convert the dragged data to a widget and add it to the destination column

setState(() {

destinationColumn.children.add(_convertToWidget(data));

sourceColumn.children.remove(data);

});

},

);


// Create a Draggable widget to drag the item from the source column

final draggable = Draggable(

child: sourceColumn,

feedback: sourceColumn,

childWhenDragging: Container(),

data: 'Data to be dragged', // Add the data to be dragged here

);


// Wrap the draggable widget with the drag target widget

return Stack(

children: [

dragTarget,

draggable,

],

);

}

}


void setState(Function function) {

// Placeholder for the real setState function

// This function is typically provided by the StatefulWidget's parent

}


void main() {

runApp(MaterialApp(

home: MyDraggableWidget(),

));

}}

1