Allow element.library to be null for dynamic (#1789)

diff --git a/lib/src/model.dart b/lib/src/model.dart
index 807ea75..c246469 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -2765,7 +2765,8 @@
     assert(library != null ||
         e is ParameterElement ||
         e is TypeParameterElement ||
-        e is GenericFunctionTypeElementImpl);
+        e is GenericFunctionTypeElementImpl ||
+        e.kind == ElementKind.DYNAMIC);
     // With AnalysisDriver, we sometimes get ElementHandles when building
     // docs for the SDK, seen via [Library.importedExportedLibraries].  Why?
     if (e is ElementHandle) {