If you are attempting to put a String variable inside another static String you can do the following for simple variables:

String firstString = 'sentence';
String secondString = 'This is a $firstString';

Which will output This is a sentence.

If the String is a property of an object, then you must use ${}like this:

person.name = 'Shilpa';
String newString = 'This is my name: ${person.name}';

Which will output This is my name: Shilpa.

Answer from J. S. on Stack Overflow
🌐
Flutter
api.flutter.dev › flutter › dart-core › String-class.html
String class - dart:core library - Dart API
Allocates a new string containing the specified charCodes. ... Value for name in the compilation configuration environment declaration.
🌐
C# Corner
c-sharpcorner.com › article › flutter-3-variable-declaration-initialization-and-discuss-with-string
Flutter 3 Variable Declaration, Initialization And Discuss With String😜
June 27, 2022 - In the above program, the string is a variable. And ‘name’ is name of the variable, any name you enter; in this case, we entered name.
🌐
Coding with Rashid
flutterforyou.com › home › how to call a variable inside string in flutter
How to call a Variable inside String in Flutter - Coding with Rashid
March 4, 2021 - Hence, let’s check how to call variables inside a string in Flutter. Calling a variable inside string is extremely easy in Flutter. You just need to use the dollar syntax as given below.
🌐
Educative
educative.io › answers › what-is-string-interpolation-in-dart
What is string interpolation in Dart?
String interpolation is the process of inserting variable values into placeholders in a string literal.
🌐
Shailen
shailen.github.io › blog › 2012 › 11 › 14 › dart-string-interpolation
Dart String Interpolation - Shailen Tuli's blog
Expressions inside ${} can be arbitrarily complex: List names = ['John', 'Sophena', 'Henrietta']; print("${ ((names) { return names[(new math.Random()).nextInt(names.length)]; })(names)} is the most valueable member of our team"); The code above defines an anonymous function to pick a random name from a list and then calls that function with names as an argument. All of this is done as part of string interpolation.
🌐
Dart
dart.dev › language › variables
Variables
Learn more · Learn about variables ... content_copy · Variables store references. The variable called name contains a reference to a String object with a value of "Bob"....
Find elsewhere
Top answer
1 of 2
5

Change this:

const ListTile(
        leading: const Icon(Icons.album),
        title: Text(_placeCard.title),
        subtitle: const Text('Come and dance tonight!'),
      );

into this:

const ListTile(
        leading: const Icon(Icons.album),
        title: const Text(_placeCard.title),
        subtitle: const Text('Come and dance tonight!'),
      );

Since in your screenshot ListTile is a constant then all the properties need to be constant also, therefore add const before Text(_placeCard.title),

2 of 2
4

Const will be assumed for Icon and Text, as they have to be constant, so that the ListTile can be constant as a whole.

So it's the same to write:

const ListTile(
    leading: const Icon(Icons.album),
    title: const Text(_placeCard.title),
    subtitle: const Text('Come and dance tonight!'),
  );

as

const ListTile(
    leading: Icon(Icons.album),
    title: Text(_placeCard.title),
    subtitle: Text('Come and dance tonight!'),
  );

But you seem to confuse the meaning of const anyway, as this probably won't work in your application.

From news.dartlang.org,

"const" has a meaning that's a bit more complex and subtle in Dart. const modifies values. You can use it when creating collections, like const [1, 2, 3], and when constructing objects (instead of new) like const Point(2, 3). Here, const means that the object's entire deep state can be determined entirely at compile time and that the object will be frozen and completely immutable

so that means that you could say

const ListTile(
    leading: Icon(Icons.album),
    title: Text("foo"),
    subtitle: Text('Come and dance tonight!'),
  );

but not create that Object constant while running the application, as you don't have all data at compile-time.

You should just not use const and then it should be alrighto.

🌐
DhiWise
dhiwise.com › post › insight-into-dart-string-interpolation-for-flutter-developers
Mastering Dart String Interpolation: Tips and Best Practices
January 2, 2025 - Besides embedding a variable in a string object, Dart string interpolation allows for embedding expressions. The expression inside the curly braces gets evaluated, and the outcome is included in the string. ... In the above example, the output will be: The sum of 5 and 2 is 7. In essence, Dart string interpolation stands as an effective way of concatenating strings and embedding expressions, thereby making the Dart and Flutter code cleaner and more efficient.
🌐
DhiWise
dhiwise.com › post › bouncing-around-the-basics-of-flutter-variables
Understanding the Fundamentals: A Guide to Flutter Variables
April 3, 2025 - In Flutter, you declare a variable by specifying its type followed by the variable name. The type could be int, String, bool, List, Map, etc. If you don't want to specify the type, you can use the var keyword, and Dart will infer the type for you.
Top answer
1 of 3
7

Dart when used in flutter doesn't support reflection.

If it's text that you want to have directly in your code for some reason, I'd advise using a text replace (using your favourite tool or using intellij's find + replace with regex) to change it into a map, i.e.

final Map<String, String> whee = {
  'XVG': 'url 1',
  'BTC': 'url 2',
};

Another alternative is saving it as a JSON file in your assets, and then loading it and reading it when the app opens, or even downloading it from a server on first run / when needed (in case the URLs need updating more often than you plan on updating the app). Hardcoding a bunch of data like that isn't necessarily always a good idea.

EDIT: how to use.

final Map<String, String> whee = .....

String getIconsURL(String symbol) {
  //symbol = 'XVG'

  return whee[symbol];
}

If you define it in a class make sure you set it to static as well so it doesn't make another each time the class is instantiated.

Also, if you want to iterate through them you have the option of using entries, keys, or values - see the Map Class documentation


2 of 3
4

I'd just implement a getProperty(String name) method or the [] operator like:

class URLsList{
  var XVG = 'some url';
  var BTC = 'some url';

  String get operator [](String key) {
    switch(key) {
      case 'XVG': return XVG;
      case 'BTC': return BTC;
    }
  }
}

String getIconsURL(String symbol) {
  var list = new URLsList();
  return list[symbol];
}

You can also use reflectable package that enables you to use reflection-like code by code generation.

🌐
O'Reilly
oreilly.com › library › view › flutter-and-dart › 9781098119508 › ch01.html
1. Learning Dart Variables - Flutter and Dart Cookbook [Book]
December 15, 2022 - Ultimately it should offer a quick technical guide as you progress in your journey to learn Dart/Flutter. Across the chapter, the code examples are self-contained and are focused on a typical use case. We start by discussing the four main variable types (i.e., int, double, bool, and String) and ...
Author   Richard Rose
Published   2022
Pages   307
🌐
Medium
medium.com › @khalidzia2023 › how-does-string-interpolation-work-in-a-flutter-text-widget-when-dealing-with-single-or-multiple-bbf8b1329745
Q: Dealing with String Interpolation in Flutter Text Widget? | by Khalidzia | Medium
September 1, 2024 - String name = 'Khalid'; Text('Hello, $name'); // Output: Hello, Khalid · In this case, "$name” is replaced by the value of the "name" variable (khalid).
🌐
FlutterFlow
docs.flutterflow.io › resources › variables
Variables | FlutterFlow Documentation
Enable the Is List toggle to indicate that this field should be of the list type. ... If the data type selected is String and the Is List toggle is enabled, FlutterFlow will create a list of String variables.
🌐
Dart
dart.dev › language › built-in-types
Built-in types
If you do this, the variable can have both integer and double values. ... // String -> int var one = int.parse('1'); assert(one == 1); ​ // String -> double var onePointOne = double.parse('1.1'); assert(onePointOne == 1.1); ​ // int -> String String oneAsString = 1.toString(); assert(oneAsString == '1'); ​ // double -> String String piAsString = 3.14159.toStringAsFixed(2); assert(piAsString == '3.14'); content_copy
🌐
Stack Overflow
stackoverflow.com › questions › 52293654 › edit-string-variable-in-flutter
dart - Edit String Variable in Flutter - Stack Overflow
what can i do, to change the value of messagePrefs variable? ... You are changing the value, but that happens after the print statement has been executed. Try adding an await before socketUtil.join(id).then( ... ) to wait for that operation to complete before continuing to the print statement. Even better, use await consistently instead of mixing it with then calls: Future<List<ChatTile>> fetchChat(socketutil,id) async { String messagePrefs = '[]'; try { var result = await sockeutil.join(id); print("DUA"); SharedPreferences prefs = await SharedPreferences.getInstance(); messagePrefs = (prefs.getString('messagePrefs') ??
🌐
Androidatc
androidatc.com › pages-78 › Dart-Variables
Dart Variables
In some cases, you may need to convert a data type for a variable to another data type such as changing an Integer to a String. To do that, you need to use toString() function explicitly to convert the variable to data type String, as illustrated in the following figure: * This topic is a part ...