openCreator method
- {required WidgetRef ref,
- required bool killOnPop,
- CreatorFieldValues? creatorFieldValues,
- List<
Subtitle> ? subtitles}
A helper function for opening the creator from any page in the application for card export purposes. Normally, the fields are provided by values in the app state. For example, the sentence field provides its value upon opening the creator from current media, which if null is empty.
Implementation
Future<void> openCreator({
required WidgetRef ref,
required bool killOnPop,
CreatorFieldValues? creatorFieldValues,
List<Subtitle>? subtitles,
}) async {
_currentMediaPauseController.add(null);
List<String> decks = await getDecks();
CreatorModel creatorModel = ref.watch(creatorProvider);
creatorModel.clearAll(
overrideLocks: true,
savedTags: savedTags,
);
if (creatorFieldValues != null) {
creatorModel.copyContext(creatorFieldValues);
}
_isCreatorOpen = true;
_creatorActiveController.add(true);
await Navigator.push(
_navigatorKey.currentContext!,
PageRouteBuilder(
opaque: false,
pageBuilder: (context, animation1, animation2) => CreatorPage(
decks: decks,
editEnhancements: false,
editFields: false,
killOnPop: killOnPop,
subtitles: subtitles,
),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
settings: RouteSettings(name: (CreatorPage).toString()),
),
);
_isCreatorOpen = false;
_creatorActiveController.add(false);
}