In the 'Write Your First App' tutorial on the Flutter docs, Step 4 titled "Step 4: Create an infinite scrolling ListView", you are asked to create 2 variables show here:
class RandomWordsState extends State<RandomWords> {
final _suggestions = <WordPair>[];
final _biggerFont = const TextStyle(fontSize: 18.0);
...
}
Why is the const
keyword used in the 3rd line? I come from a C# and JavaScript background and I'm not used to seeing this on the right side of an assignment statement. I notice if I remove it it still works as I expected. Could you please explain in lamens terms why this is being used and when should I do the same? I'm guessing it's overkill and I don't have to use it but I just want to make sure.
I do not believe this is a duplicate because the answer in this post was perfect in explaining my question and not found in the other post, not to mention the other post is a two part question that nobody would find when using google.