Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elementAt().getAttribute() works in debug mode but won't compile #57

Closed
mwpierce63 opened this issue Mar 12, 2019 · 1 comment
Closed

Comments

@mwpierce63
Copy link

mwpierce63 commented Mar 12, 2019

When I use the following line in debug mode or compile a debug build it works fine but when I try to make a profile or release build the consumes all memory then crashes. Here's a snippet:

// Open up the xml file of recipes
    String recipesXML = await rootBundle.loadString('xmlfiles/recipes.xml');
    // Open up the xml parser and parse in the recipes
    xml.XmlDocument recipebook = xml.parse(recipesXML);
    // get an iterator that can walk through the list of recipes
    Iterable<xml.XmlElement> recipeObjs = recipebook.findAllElements('RcpE');
    Iterable<xml.XmlElement> subObjs;
 for (int idx = 0; idx < numRecipes; idx++) {
      recipes.add(new Recipe.empty());
      recipes.elementAt(idx).name =
          recipeObjs.elementAt(idx).getAttribute("name").toString();
      recipes.elementAt(idx).author =
          recipeObjs.elementAt(idx).getAttribute("author").toString();
      recipes.elementAt(idx).imagePath = 'photos/' +
          recipes
              .elementAt(idx)
              .name
              .replaceAll(' ', '_')
              .replaceAll('&', 'and')
              .replaceAll('-', '_')
              .replaceAll("'", '')
              .replaceAll('__', '_')
              .replaceAll(',', '')
              .toLowerCase() +
          '.jpg'; 
      // get servings
      subObjs = recipeObjs.elementAt(idx).findElements('Serv');
//      THE BELOW LINE CAUSES RELEASE or PROFILE BUILDS TO FAIL
      recipes.elementAt(idx).servings =
          int.tryParse(subObjs.elementAt(0).getAttribute("qty")) ?? 1;
@renggli
Copy link
Owner

renggli commented Mar 12, 2019

I think you should report this to the Flutter bug-tracker, assuming that you are talking about Flutter and this happens during compile-time? Also, it would help if you could provide a self-contained minimal example, because with the provided code I cannot reproduce the problem (numRecipes is not defined, the xml file does not exist, etc.).

@renggli renggli closed this as completed Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants