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);
@override
Widget build(BuildContext context) {
var myList = MyList(context);
/* ... */
}
}
class MyList {
final BuildContext context;
MyList(this.context);
/* ... */
}