Last active
March 2, 2025 16:35
-
-
Save fredgrott/0e2b65c3bf559a2b05e2a27d199f77b0 to your computer and use it in GitHub Desktop.
extension and data fixture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'company_model.dart'; | |
extension CompanyFixture on Company{ | |
static _CompanyFixtureFactory factory() => _CompanyFixtureFactory(); | |
} | |
class _CompanyFixtureFactory extends FixtureFactory<Company>{ | |
@override | |
FixtureDefinition<Company> defintion() => define( | |
(faker) => Company( | |
id: Uuid().v4(), | |
name: faker.company.name(), | |
emplyoees: PersonFixturer.factory().makeMany(5), | |
), | |
); | |
FixureDefinition<Company> empty(String name) => redefine( | |
(company) => Company( | |
id: Uuid().v4(), | |
name: name, | |
employees: [], | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment