I want to run a block of code in whole flutter app(in every screens).
Scenario: I have an intent in android layer for attaching usb device to the android device. And I want to show a dialog when the intent is triggered.
I try to write this on MyApp initState
block, but dialog is not shown, or I get this error:
Unhandled Exception: No MaterialLocalizations found.
MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
see this question for not showing my dialog.
But now, My question is how to run a block of code in every screen of flutter app?