Change Flutter Localizations With Bloc State Managment Problem
I would like to change application language every time that someone decide to change application language without restarting app. Everything is working using BLoC.
The problem I have I don't really understand one thing. If I pass to
TodosLocalizations.of(context).translate("appTitle") it throws an error:
The method 'translate' was called on null. Receiver: null Tried calling: translate("appTitle")
But when I comment this line and pass the same thing to
onGenerateTitle property using
context everything is working without problem.
Can someone answer me why this happening or I might don't understand how to use this property (title) in this case.
When you call onGenerateTitle: (BuildContext context) => TodosLocalizations.of(context).title, it uses a new BuildContext, which already contains the LocalizedDelagate(), so it can be called with TodosLocalizations.of(context).
When you use it directly without onGenerateTitle within the same build method, you refer to an instance of context before the LocalizedDelagate() was created, so TodosLocalizations.of(context) doesn't return anything.
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?