Provider: Difference from Singleton

Created on 3 May 2019  路  1Comment  路  Source: rrousselGit/provider

I wonder if Inherited widget is more performant then using Singleton

Most helpful comment

More performant than Singleton, no. But they are pretty fast, (O(1) + a constant factor) so the difference is almost non-existent.

But besides performance, there are a couple of strong points that Singletons do not have.

They:

  • act as an abstraction.
  • are scoped and overridable
  • force structured object graph due to the tree nature and unidirectional data-flow of widgets.
  • ensure that dependents are always up to date

>All comments

More performant than Singleton, no. But they are pretty fast, (O(1) + a constant factor) so the difference is almost non-existent.

But besides performance, there are a couple of strong points that Singletons do not have.

They:

  • act as an abstraction.
  • are scoped and overridable
  • force structured object graph due to the tree nature and unidirectional data-flow of widgets.
  • ensure that dependents are always up to date
Was this page helpful?
0 / 5 - 0 ratings