plugins/file_chooser/windows/file_chooser_plugin.cpp
// Displays the open or save dialog (according to |type|) and sends the
// selected file path(s) back to the engine via |result|, or sends an
// error on failure.
//
// |result| is guaranteed to be resolved by this function.
Displays the open or save dialog (according to |type|) and sends the
selected file path(s) back to the engine via |result|, or sends an
error on failure.

|result| is guaranteed to be resolved by this function.
Displays the open or save dialog ( according to |type| ) and sends the selected file path ( s ) back to the engine via |result| or sends an error on failure . |result| is guaranteed to be resolved by this function .
void ShowDialog(
    IID type, HWND parent_window, const EncodableMap &args,
    std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
  DialogWrapper dialog(type);
  if (!SUCCEEDED(dialog.last_result())) {
    EncodableValue error_code(dialog.last_result());
    result->Error("System error", "Could not create dialog", &error_code);
    return;
  }
  FILEOPENDIALOGOPTIONS dialog_options = 0;
  EncodableValue allow_multiple_selection =
      ValueOrNull(args, kAllowsMultipleSelectionKey);
  if (!allow_multiple_selection.IsNull() &&
      allow_multiple_selection.BoolValue()) {
    dialog_options |= FOS_ALLOWMULTISELECT;
  }
  EncodableValue choose_dirs = ValueOrNull(args, kCanChooseDirectoriesKey);
  if (!choose_dirs.IsNull() && choose_dirs.BoolValue()) {
    dialog_options |= FOS_PICKFOLDERS;
  }
  if (dialog_options != 0) {
    dialog.AddOptions(dialog_options);
  }
  EncodableValue start_dir = ValueOrNull(args, kInitialDirectoryKey);
  if (!start_dir.IsNull()) {
    dialog.SetDefaultFolder(start_dir.StringValue());
  }
  EncodableValue initial_file_name = ValueOrNull(args, kInitialFileNameKey);
  if (!initial_file_name.IsNull()) {
    dialog.SetFileName(initial_file_name.StringValue());
  }
  EncodableValue confirm_label = ValueOrNull(args, kConfirmButtonTextKey);
  if (!confirm_label.IsNull()) {
    dialog.SetOkButtonLabel(confirm_label.StringValue());
  }
  EncodableValue allowed_types = ValueOrNull(args, kAllowedFileTypesKey);
  if (!allowed_types.IsNull() && !allowed_types.ListValue().empty()) {
    dialog.SetFileTypeFilters(allowed_types.ListValue());
  }
  EncodableValue files = dialog.Show(parent_window);
  if (files.IsNull() &&
      dialog.last_result() != HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
    EncodableValue error_code(dialog.last_result());
    result->Error("System error", "Could not show dialog", &error_code);
  }
  EncodableValue response(std::move(files));
  result->Success(&response);
}
void ShowDialog ( IID type , HWND parent_window , const EncodableMap & args , std :: unique_ptr < flutter :: MethodResult < flutter :: EncodableValue > > result ) { DialogWrapper dialog ( type ) ; if ( ! SUCCEEDED ( dialog . last_result ( ) ) ) { EncodableValue error_code ( dialog . last_result ( ) ) ; result -> Error ( " " , " " , & error_code ) ; return ; } FILEOPENDIALOGOPTIONS dialog_options = 0 ; EncodableValue allow_multiple_selection = ValueOrNull ( args , kAllowsMultipleSelectionKey ) ; if ( ! allow_multiple_selection . IsNull ( ) && allow_multiple_selection . BoolValue ( ) ) { dialog_options |= FOS_ALLOWMULTISELECT ; } EncodableValue choose_dirs = ValueOrNull ( args , kCanChooseDirectoriesKey ) ; if ( ! choose_dirs . IsNull ( ) && choose_dirs . BoolValue ( ) ) { dialog_options |= FOS_PICKFOLDERS ; } if ( dialog_options != 0 ) { dialog . AddOptions ( dialog_options ) ; } EncodableValue start_dir = ValueOrNull ( args , kInitialDirectoryKey ) ; if ( ! start_dir . IsNull ( ) ) { dialog . SetDefaultFolder ( start_dir . StringValue ( ) ) ; } EncodableValue initial_file_name = ValueOrNull ( args , kInitialFileNameKey ) ; if ( ! initial_file_name . IsNull ( ) ) { dialog . SetFileName ( initial_file_name . StringValue ( ) ) ; } EncodableValue confirm_label = ValueOrNull ( args , kConfirmButtonTextKey ) ; if ( ! confirm_label . IsNull ( ) ) { dialog . SetOkButtonLabel ( confirm_label . StringValue ( ) ) ; } EncodableValue allowed_types = ValueOrNull ( args , kAllowedFileTypesKey ) ; if ( ! allowed_types . IsNull ( ) && ! allowed_types . ListValue ( ) . empty ( ) ) { dialog . SetFileTypeFilters ( allowed_types . ListValue ( ) ) ; } EncodableValue files = dialog . Show ( parent_window ) ; if ( files . IsNull ( ) && dialog . last_result ( ) != HRESULT_FROM_WIN32 ( ERROR_CANCELLED ) ) { EncodableValue error_code ( dialog . last_result ( ) ) ; result -> Error ( " " , " " , & error_code ) ; } EncodableValue response ( std :: move ( files ) ) ; result -> Success ( & response ) ; }
Displays the open or save dialog (according to |type|) and sends the
selected file path(s) back to the engine via |result|, or sends an
error on failure.
Displays the open or save dialog ( according to |type| ) and sends the selected file path ( s ) back to the engine via |result| or sends an error on failure .