I'm a beginner at Flutter/Dart and I keep seeing dollar signs appearing before calls to classes or methods, an example is the following (found in Floor package documentation):
final database = await $FloorAppDatabase.databaseBuilder('app_database.db').build();
I've searched a lot and the only meaning of dollar signs in Dart that I could find is for string interpolation, but this doesn't seem the case.
It's not a Flutter or Dart convention - at least not an official one: the official Dart naming conventions document (as of October 2020) makes no mention of using
$
in identifier names.However, I do know that other programming languages' ecosystems do use a dollar-sign (Sigil) and I think that habit was inherited by the authors of the
floor
database that you linked to. More specifically, in Java it's commonplace to use a$
prefix for type-names generated by tooling rather than being hand-written (such as ORM entity types, for example), and people using RxJS observables in JavaScript will use a$
as a variable-name suffix.As
$FloorDatabase
is a type-name, not a variable or member-name, I'm going to go with the assumption it's a habit picked-up from Java:So in this case, a clue is in the documentation you linked to:
So that's my conclusion: it's not an official naming convention in Dart/Flutter, but it is in Java, and it seems like the authors of
floor
carried it over from Java.(I personally wish they didn't as it isn't a particularly useful indicator - what does it matter to a consuming application if a type was created a tool instead of hand-written?)