Search code examples
flutterriverpod

Is it safe to pass BuildContext to family provider as a parameter using flutter riverpod?


Is it safe to pass buildContext in flutter as a parameter to a family provider using flutter riverpod?


Solution

  • Is it safe? Yes. Nothing terrible will happen

    Is it a bad practice? Also yes. Your providers should be independent from the UI. And relying on BuildContext may make it difficult to obtain your provider's state in a different place.