openBestChoice static method

Future<void> openBestChoice({
  1. required PagedProductQuery productQuery,
  2. required LocalDatabase localDatabase,
  3. required String name,
  4. required BuildContext context,
  5. bool editableAppBarTitle = true,
  6. bool searchResult = true,
  7. SearchQueryCallback? editQueryCallback,
})

Implementation

static Future<void> openBestChoice({
  required PagedProductQuery productQuery,
  required LocalDatabase localDatabase,
  required String name,
  required BuildContext context,
  bool editableAppBarTitle = true,
  bool searchResult = true,
  SearchQueryCallback? editQueryCallback,
}) async {
  final Widget widget = await getBestChoiceWidget(
    productQuery: productQuery,
    localDatabase: localDatabase,
    name: name,
    context: context,
    editableAppBarTitle: editableAppBarTitle,
    searchResult: searchResult,
  );

  if (!context.mounted) {
    return;
  }

  final bool? result = await Navigator.of(context).push<bool>(
    MaterialPageRoute<bool>(builder: (BuildContext context) => widget),
  );

  if (result == true) {
    editQueryCallback?.call(name);
  }
}