I’m using Flutter pdf package inside my project (https://pub.dev/packages/pdf). The package generates a document which I show on the screen. I want to add localisation (localised Text fields) into my generated pdf document but AppLocalizations.of(context) requires BuildContext, not just a Context.
As I understood, generated pdf file is not a part of material Scaffold, so there is no way to access BuildContext.
Page constructor
Any ideas how to get access to BuildContext when I configure localised Text strings in my pdf Page?
I tried to find the answer on package page and package repo, but I have not found any solution so far.
2
Answers
instead of passing the context, try to call AppLocalizations as a singleton without passing the context. some intl libraries provide singlton, if you couldn’t find any, try to store the instance in GetIt , or build your own technique and store it in main widget.
A bit complicated but it works.