showNewFunctionSheet function

void showNewFunctionSheet(
  1. BuildContext context, {
  2. required List<String> existingCustomFunctionNames,
  3. required dynamic onSaved(
    1. String newName,
    2. DartBlockDataType? newReturnType
    ),
  4. required dynamic onReceiveDartBlockNotification(
    1. DartBlockNotification notification
    )?,
})

Implementation

void showNewFunctionSheet(
  BuildContext context, {
  required List<String> existingCustomFunctionNames,
  required Function(String newName, DartBlockDataType? newReturnType) onSaved,

  /// If the context is the same as the main DartBlockEditor's context, indicate
  /// this argument to handle incoming DartBlockNotifications.
  /// Otherwise, the notifications will be automatically propagated upwards.
  required Function(DartBlockNotification notification)?
  onReceiveDartBlockNotification,
}) {
  HapticFeedback.mediumImpact();

  showAdaptiveBottomSheetOrDialog(
    context,
    sheetPadding: EdgeInsets.all(8),
    dialogPadding: EdgeInsets.all(16),
    onReceiveDartBlockNotification: onReceiveDartBlockNotification,
    child: CustomFunctionBasicEditor(
      existingCustomFunctionNames: existingCustomFunctionNames,
      canDelete: false,
      canChange: true,
      onDelete: () {},
      onSaved: (newName, newReturnType) {
        Navigator.of(context).pop();
        onSaved(newName, newReturnType);
      },
    ),
  );
}