skip to Main Content

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

2

Answers


  1. Don’t pass build context in the riverpod. Build context should be local to the screen. Don’t make it global.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search