Problem with custom code

Custom Code

I have a problem, I have a custom code with a sortable grid, which is filled with a list of appstate, each of the elements has a button to remove it from the list, well, when I click to remove it from the list I add it to another one in which I save the values to generate buttons and when the button is pressed I add it to the list of the grid, the problem I have is that when I click on the icon to remove it from the grid list, it takes up to 2 seconds to be added to the list of buttons, any idea, I share my custom code.

// Automatic FlutterFlow imports import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart';
// Imports other custom widgets import '/custom_code/actions/index.dart';
// Imports custom actions import '/flutter_flow/custom_functions.dart';
// Imports custom functions import 'package:flutter/material.dart';
// Begin custom widget code // DO NOT REMOVE OR MODIFY THE CODE ABOVE! //import 'package:jwt_mmnews/pages/hometest/hometest_model.dart';
//import 'package:provider/provider.dart';
import 'package:jwt_mmnews/components/choice_keywords/choice_keywords_widget.dart';
import 'package:jwt_mmnews/flutter_flow/flutter_flow_icon_button.dart';
import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:reorderable_grid/reorderable_grid.dart';
class NewCustomWidget extends StatefulWidget{
  const NewCustomWidget({
    super.key, this.width, this.height, this.lista, this.id, this.size,
  }
  );
  final double? width;
  final double? height;
  final List<ElementosListaPlayerStruct>? lista;
  final int? id;
  final double? size;
  @override State<NewCustomWidget> createState() => _NewCustomWidgetState();

}
class _NewCustomWidgetState extends State<NewCustomWidget>{
  @override void initState(){
    super.initState();

  }
  @override void dispose(){
    super.dispose();

  }
  @override Widget build(BuildContext context){
    return ReorderableGridView.extent( primary: false, cacheExtent: 80, maxCrossAxisExtent: MediaQuery.sizeOf(context).width < kBreakpointSmall ? 600 : MediaQuery.sizeOf(context).width < kBreakpointMedium ? 500 : MediaQuery.sizeOf(context).width < kBreakpointLarge ? 200 : 600, shrinkWrap: true, mainAxisSpacing: 2.0, onReorder: (oldIndex, newIndex){
      setState((){
        final item = widget.lista!.removeAt(oldIndex);
        widget.lista!.insert(newIndex, item);

      }
      );

    }
    , childAspectRatio: 1, children: List.generate(widget.lista!.length, (index){
      final item = widget.lista![index];
      return Padding( key: ValueKey(item.titulo), padding: EdgeInsetsDirectional.fromSTEB(0, 0, 12, 10), child: Card( clipBehavior: Clip.antiAliasWithSaveLayer, color: FlutterFlowTheme.of(context).secondaryBackground, elevation: 3, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(6), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(16, 16, 10, 0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( item.titulo, style: FlutterFlowTheme.of(context).labelSmall.override( fontFamily: 'Plus Jakarta Sans', fontSize: 16, ), ), ), Builder( builder: (context) => Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 0, 3, 0), child: FlutterFlowIconButton( borderColor: FlutterFlowTheme.of(context).alternate, borderRadius: 12, borderWidth: 2, buttonSize: 39, fillColor: FlutterFlowTheme.of(context).accent4, icon: Icon( Icons.copy_all, color: FlutterFlowTheme.of(context).primaryText, size: 19, ), onPressed: () async{
        await item.slug == 'keywords' ? Clipboard.setData(ClipboardData( text: item.keywords.toString())) : Clipboard.setData( ClipboardData(text: item.descripcion));

      }
      , ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 0, 3, 0), child: FlutterFlowIconButton( borderColor: FlutterFlowTheme.of(context).alternate, borderRadius: 12, borderWidth: 2, buttonSize: 39, fillColor: FlutterFlowTheme.of(context).accent4, icon: Icon( Icons.clear, color: FlutterFlowTheme.of(context).primaryText, size: 19, ), onPressed: (FFAppState().listDrawer.length == 1 || item.slug == 'keywords') ? null : (){
        setState((){
          FFAppState() .removeAtIndexFromListDrawer(index);
          FFAppState().addToListaBotones( ElementosListaPlayerStruct( titulo: item.titulo, show: false, keywords: item.keywords, descripcion: item.descripcion));

        }
        );

      }
      ), ), ], ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(23, 12, 23, 12), child: Container( height: FFAppState().listDrawer.length == 1 ? MediaQuery.of(context).size.height * 0.4 : MediaQuery.of(context).size.height * 0.3, child: ListView( padding: EdgeInsets.zero, shrinkWrap: true, primary: true, scrollDirection: Axis.vertical, children: [ Builder(builder: (context){
        if (item.slug != 'keywords'){
          return Align( alignment: AlignmentDirectional(0, 0), child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 3, 20, 3, 20), child: SelectionArea( child: Text(item.descripcion, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context) .primaryText, fontSize: widget.size, )), )));

        }else{
          return ChoiceKeywordsWidget( id: widget.id, keywords: item.keywords, );

        }

      }
      ), ], ), ), ), ], ), ), );

    }
    ).toList(), );

  }

}
What have you tried so far?

I tried to set the variables as persistent and it doesn't work.

Did you check FlutterFlow's Documentation for this topic?
No
2