I tried getting some help from stack and l can across this Python code
I would like to know how to convert this into dart and use it to get ordinal numbers
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n//10%10!=1)*(n%10<4)*n%10::4])
I made a package for this using the native platform libraries.
https://pub.dev/packages/ordinal_formatter
final ordinalString = await OrdinalFormatter().format(2) ?? '';
// -> 2nd
final localisedOrdinalString = await OrdinalFormatter().format(2, 'en_US') ?? '';
// -> 2nd