0

I am trying to understand how to use extension methods in dart/flutter.

the extension

extension on Text {
  Text get boldCardTitle {
    
    return Text(this.data!, style:const TextStyle(fontSize: 20, fontWeight: FontWeight.w500) );
  }
  
}

I am trying to do something like this, and have it inherit those styles

Text('5401 Odom Ave \nFort Worth, TX 76114').boldCardTitle,
bihire boris
  • 1,530
  • 3
  • 19
  • 44

1 Answers1

1

You have to give a name for the extension:

extension TextExtension on Text {
  ...
}
Roslan Amir
  • 1,141
  • 8
  • 16