Skip to content

How to parameterise a container? #174

Closed Answered by GregoryConrad
opsb asked this question in Q&A
Discussion options

You must be logged in to vote

@opsb for your particular case that sparked this question, you could do:

ValueWrapper<int> startingCountCapsule(CapsuleHandle use) => use.data(0);
(int, void Function()) countCapsule(CapsuleHandle use) {
  final count = use.data(use(startingCountCapsule).value);
  return (count.value, () => count.value++);
}

// test_utils.dart
CapsuleContainer useContainerWithStartingCount(int startingCount) {
  final container = CapsuleContainer();
  container.read(startingCountCapsule).value = startingCount;
  addTearDown(container.dispose);
  return container;
}

NOTE: I haven't tested the above, but I see no reason it shouldn't work.

The environment variables idea posted previously can also help for s…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
5 replies
@busslina
Comment options

@opsb
Comment options

@busslina
Comment options

@busslina
Comment options

@opsb
Comment options

Comment options

You must be logged in to vote
4 replies
@busslina
Comment options

@opsb
Comment options

@busslina
Comment options

@GregoryConrad
Comment options

Answer selected by GregoryConrad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants