You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling ensureInitialized() for every mapper in your project can be cumbersome. Therefore you can generate an initializer functions that automatically initializes all mappers in scope.
To do this set the generateInitializerForScope property on @MappableLib(), which replaces the createCombinedContainer property.
When creating a library which does not have a main method, such as one for communicating with an API, should initializeMappers() be called when the class is constructed or somewhere else? What happens if it gets called more than once? What if the library is then used in a larger project which is also using dart_mappable?
The following breaking changes need to be migrated when upgrading to version 3.x:
Mapper Container
<ClassName>Mapper.container
s are removedInstead use the global
MapperContainer.globals
container.Initializing Mappers
Mappers can be used
MyClassMapper.fromJson(json)
, orMapperContainer.globals.fromJson<MyClass>(json)
.When used implicitly, mappers must be initialized beforehand by calling their
MyClassMapper.ensureInitialized()
method.Generated Initializer
Calling
ensureInitialized()
for every mapper in your project can be cumbersome. Therefore you can generate an initializer functions that automatically initializes all mappers in scope.To do this set the
generateInitializerForScope
property on@MappableLib()
, which replaces thecreateCombinedContainer
property.The text was updated successfully, but these errors were encountered: