FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
130 stars 26 forks source link

Can't create custom code #4810

Closed LoginPanel07 closed 1 day ago

LoginPanel07 commented 2 weeks ago

Can we access your project?

Current Behavior

Im trying to create a custom action and function, but none of them are getting saved even though im pressing the Save Function button.

Expected Behavior

It should just save and stay in it's category

Steps to Reproduce

  1. Add a custom action or function
  2. Write something in it
  3. Press save

Reproducible from Blank

Bug Report Code (Required)

Icannotextractbugreportcode,nothinghappenswhenirightclickafterchoosingapage

Visual documentation

image image

Environment

- FlutterFlow version: 5.0.8+
- Platform: PC browser and app
- Browser name and version: Chrome 130.0.6723.92
- Operating system and version affected: Windows 11

Additional Information

No response

chuggmuffinReturns commented 2 weeks ago

@LoginPanel07 the action name and the function need to have the same name

chuggmuffinReturns commented 2 weeks ago

ie not called newCustomAction but paseSiteMapXML

LoginPanel07 commented 2 weeks ago

But i can’t create either of them

chuggmuffinReturns @.***> (időpont: 2024. nov. 3., V, 19:57) ezt írta:

@LoginPanel07 https://github.com/LoginPanel07 the action name and the function need to have the same name

— Reply to this email directly, view it on GitHub https://github.com/FlutterFlow/flutterflow-issues/issues/4810#issuecomment-2453540671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO7X5E3SBANNIB5CQCSE7ZTZ6ZPXXAVCNFSM6AAAAABRC3VZ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJTGU2DANRXGE . You are receiving this because you were mentioned.Message ID: @.***>

LoginPanel07 commented 2 weeks ago

So i should leave it newcustomaction and it will work?

chuggmuffinReturns @.***> (időpont: 2024. nov. 3., V, 19:58) ezt írta:

ie not called newCustomAction but paseSiteMapXML

— Reply to this email directly, view it on GitHub https://github.com/FlutterFlow/flutterflow-issues/issues/4810#issuecomment-2453540916, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO7X5E6HMXHPOLHL3MQJ2KDZ6ZP3TAVCNFSM6AAAAABRC3VZ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJTGU2DAOJRGY . You are receiving this because you were mentioned.Message ID: @.***>

LoginPanel07 commented 2 weeks ago

[image: image.png] As you can see I cannot create any actions or functions. The problem is definitely not that their names are not the same cause there is not a single one to have the same name with, as i cannot create a single function.

chuggmuffinReturns @.***> ezt írta (időpont: 2024. nov. 3., V, 19:58):

ie not called newCustomAction but paseSiteMapXML

— Reply to this email directly, view it on GitHub https://github.com/FlutterFlow/flutterflow-issues/issues/4810#issuecomment-2453540916, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO7X5E6HMXHPOLHL3MQJ2KDZ6ZP3TAVCNFSM6AAAAABRC3VZ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJTGU2DAOJRGY . You are receiving this because you were mentioned.Message ID: @.***>

Alezanello commented 2 weeks ago

Hello!

As chuggmuffinReturns mentioned, to save an action correctly, you need to set a name for the action in the title field. It looks like the images you shared in your follow-up comments aren’t visible—this may be due to replying via email. Could you please upload the images directly here on GitHub? Alternatively, a short screen recording (e.g., using Loom) showing the issue would be very helpful. A brief clip will work; just a quick walkthrough of the steps you’re taking.

Thank you!

P.S: Here is the documentation with a lot of videos on how to do it properly: https://docs.flutterflow.io/concepts/custom-code/

image.png
LoginPanel07 commented 2 weeks ago

image Here is the picture, as you can see they are the same name

Alezanello commented 2 weeks ago

In this case, you need to add the Arguments (the string you expect to receive) and the Return Value.

Alezanello commented 2 weeks ago

Please do not set this as a Function but as an Action

LoginPanel07 commented 2 weeks ago

Yeah sorry, i did it like that first, but i thought i was doing it wrong. As you can see on the picture, It is not saved, even though i clicked on save and confirmed it. It says i saved it, but as you can see on the left there are still 0 custom actions, and when i click away from there the code doesn't disappear, but it says it's an unsaved code that it restored.(all i need is the series list, and i set a return for it at the end, as well as there is an Argument (String xmlData)) image image image

LoginPanel07 commented 2 weeks ago

Oh, im sorry, i didn't see the sidebar with the define arguments and return value. I'm guessing i should have set those up too, and that's what you are saying?

LoginPanel07 commented 2 weeks ago

I set them up, and saved, however the same problem still persists: image

LoginPanel07 commented 2 weeks ago

Can you create the custom action with the following action, save it and have it stay? Here is the code:

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';
import 'package:xml/xml.dart' as xml;

List<Map<String, dynamic>> parseSitemapXML(String xmlData) {
  final document = xml.parse(xmlData);
  final urls = document.findAllElements('loc');
  final List<Map<String, dynamic>> seriesList = [];

  for (var url in urls) {
    final pageUrl = url.text;
    if (pageUrl.contains('chapter')) {
      final trimmedUrl = pageUrl
          .replaceAll('https://spiderscans.xyz/', '')
          .replaceAll('/', '');
      final parts = trimmedUrl.split('-');

      final chapterNumber = parts.removeLast();
      final seriesName =
          parts.join(' ').replaceAll('-', ' ').replaceAll('Chapter', '').trim();
      seriesList.add({
        'name': seriesName,
        'chapter': chapterNumber,
        'url': pageUrl,
      });
    }
  }
  return seriesList;
}
chuggmuffinReturns commented 2 weeks ago

@LoginPanel07 I think the problem is in your return type not being a custom data type.

https://www.loom.com/share/d38f4c7a6d2f41d0930d725daf7d369d

Get ChatGPT to walk you through it... I started here a bit but didnt get to the end but may offer some hints

https://www.loom.com/share/daecc04b42dc4455912e8b74ef2a4275

LoginPanel07 commented 2 weeks ago

Thank you very much for your help, i was finally able to save(and ChatGPT fixed my code after trying to use the map type 4 times again XD), however i found some problems. The first is that it won't let me choose the custom data type, and instead automatically changes to json when saving(not sure if it's a problem and interferes with the program or not, i have created the the custom data type properly though, 3 strings with list attributes), the other problem is that it does not recognize the xml import, the third is that it just randomly out of the blue(it didn't have any troubles with it checking it multiple times), it does not recognize parse. Once again im very thankful for your help Bryan. image Code(if needed):

// 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/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!

import 'package:xml/xml.dart' as xml;

List parseSeriesNames(String xmlData) {
  final document = xml.parse(xmlData);
  final urls = document.findAllElements('loc');

  final List names = [];
  final List chapters = [];
  final List links = [];

  final baseUrl = "https://spiderscans.xyz/";

  for (var url in urls) {
    final pageUrl = url.text;

    if (pageUrl.contains('chapter')) {
      final trimmedUrl = pageUrl.replaceAll(baseUrl, "").replaceAll('/', '');
      final parts = trimmedUrl.split('-');

      final chapterNumber = parts.removeLast();
      final seriesName = parts.join(' ').replaceAll('-', ' ').replaceAll('Chapter', '').trim();

      names.add(seriesName);
      chapters.add(chapterNumber);
      links.add(pageUrl);
    }
  }
  return [names, links, chapters];
}
chuggmuffinReturns commented 2 weeks ago

Missing a super key point about how this works... @LoginPanel07

https://www.loom.com/share/9d05fe7886e1407682745f68135e294f

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.