I have an android java pattern that I would like to convert to something similar in flutter. It's pretty straight forward but I am having difficulty finding a clear example. What this involves is having a utility class that does repetitive string manipulation routines that I can use anywhere in the project.
Here is an example. I use the CapEachWord routine in a lot of source members. See the arrow below.
import com.auto.accident.report.util.utils;
@Override
public void onResults(Bundle results) {
ArrayList<String> result = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
switch (REQ_CODE) {
case REQ_CODE_NOTE_SUBJECT: {
DA_RESULT = utils.capEachWord(DA_RESULT); <-------------------
tieAN_SUBJECT.setText(DA_RESULT);
startNoteInput();
break;
}
}
CapEachWord resides in a source member called utils and looks like this.
public class utils {
public static String capEachWord(String DA_RESULT) {
int splitLength;
int index = 0;
String[] words = DA_RESULT.split(" ");
splitLength = words.length;
StringBuilder DA_RESULTBuilder = new StringBuilder();
while (index < splitLength) {
int DA_SIZE = words[index].length();
words[index] = words[index].substring(0,
1).toUpperCase() +
words[index].substring(1,
DA_SIZE);
DA_RESULTBuilder.append(words[index]);
if (index != splitLength) {
DA_RESULTBuilder.append(" ");
}
index++;
}
DA_RESULT = DA_RESULTBuilder.toString();
return DA_RESULT;
}
}
What I need to know is how to properly include the utils, structure the utils member and and ask for the conversion result. The actual conversion code I can work out myself.