How to reference string keys in Flutter without context?

In general, there is no clean solution here. 😔
In most cases, you'll end up with tightly coupled app layers.
Passing the context to the non-widget piece of the code (e.g. model class) that needs to be localized is perhaps the simplest approach.

class MyWidget extends StatelessWidget {
  const MyWidget({Key? key}): super(key: key);

  Widget build(BuildContext context) {

    var myList = MyList(context);

    /* ... */

class MyList {
  final BuildContext context;


  /* ... */

Flutter internationalization tutorial:

Copyrights 2024 © Localizely