error 027 invalid character constant

this is the code i have and i keep getting an error at this point

where the two single quotes are saying «invalid character constant» I’m not sure what i am doing wrong. any tips?

2 Answers 2

There is no empty character. Based on the comment, you should be using ‘a’, ‘e’, ‘i’ .

There is no such thing as a blank character. It is possible to have an empty String — that would be a String with zero characters in it. But a character always has a value.

Even if your code somehow compiled, it would be checking for an impossibility — tweet.charAt(i) is going to return the character at location i . How could there not be a character at that location? (If it was off the end of the String, it would throw an exception.)

If you wanted to check for a space, you could use ‘ ‘ instead of » . A space is a valid character that the compiler is happy to let you use.

The following code compiles and runs (but doesn’t extract the vowels; you didn’t show us that code and it’s outside the scope of this question anyway.) It’s almost identical to what you have, except I changed that » to ‘ ‘ and added the obvious stuff to make it compile.

Comments

Copy link Quote reply

rxlabz commented Apr 28, 2017 •

I noticed that when I open a Flutter file containing const Text(‘foo’) , everything works, I can compile and launch the app, but the dart analysis show me a «invalid constant value» .

if I replace the const Text by a new Text , the error disappears.

Оцените статью