Repository: dart-lang/dartdoc (dart)

Issue:
Nullable Function callbacks render incorrectly
https://master-api.flutter.dev/flutter/dart-async/StreamController/onListen.html

```
(void Function?()?) onListen
```

There's an extra `?`.

Pull request description:
Fixes https://github.com/dart-lang/dartdoc/issues/2381

Patch:
diff --git a/lib/src/render/element_type_renderer.dart b/lib/src/render/element_type_renderer.dart
index eca1552bb7..66fa8deebe 100644
--- a/lib/src/render/element_type_renderer.dart
+++ b/lib/src/render/element_type_renderer.dart
@@ -90,7 +90,6 @@ class FunctionTypeElementTypeRendererHtml
           ..write('</span>&gt;');
       }
     }
-    buffer.write(elementType.nullabilitySuffix);
     return buffer.toString();
   }
 }
@@ -253,7 +252,7 @@ class FunctionTypeElementTypeRendererMd
           ..write('>');
       }
     }
-    return wrapNullabilityParens(elementType, buffer.toString());
+    return buffer.toString();
   }
 }
 


Test patch:
diff --git a/test/element_type_test.dart b/test/element_type_test.dart
index e86c214d6c..af7cd26d34 100644
--- a/test/element_type_test.dart
+++ b/test/element_type_test.dart
@@ -176,31 +176,34 @@ void f(int Function(String)? p) {}
       expect(
         parameterType.linkedName,
         // TODO(https://github.com/dart-lang/dartdoc/issues/2381): Fix.
-        '($intLink Function?'
+        '($intLink Function'
         '<span class="signature">'
         '(<span class="parameter" id="param-">'
         '<span class="type-annotation">$stringLink</span>'
         '</span>)</span>?)',
       );
-      expect(parameterType.nameWithGenerics, equals('Function?'));
+      expect(parameterType.nameWithGenerics, equals('Function'));
     });
 
     test('generic function type has rendered names', () async {
       final library = await bootPackageWithLibrary('''
-void f(int Function(String) p) {}
+void f(int Function<T>(T)? p) {}
 ''');
       final fFunction = library.functions.named('f');
       final parameterType = fFunction.parameters.single.modelType;
 
       expect(
         parameterType.linkedName,
-        '$intLink Function'
+        '($intLink Function'
+        '&lt;<wbr><span class="type-parameter">T</span>&gt;'
         '<span class="signature">'
         '(<span class="parameter" id="param-">'
-        '<span class="type-annotation">$stringLink</span>'
-        '</span>)</span>',
+        '<span class="type-annotation">T</span></span>)</span>?)',
+      );
+      expect(
+        parameterType.nameWithGenerics,
+        'Function&lt;<wbr><span class="type-parameter">T</span>&gt;',
       );
-      expect(parameterType.nameWithGenerics, equals('Function'));
     });
   });