Generic methods for BuildContext

Supported by fix tool: Yes

Several methods in BuildContext were using Type to search for ancestors. Most of those methods
implied a cast at call site because their return type was a parent type. Moreover the type provided
was not checked at analysis time even if the type is actually constrained. Making these methods
generics improves type safety and requires less code.

These method changes affect the BuildContext, Element, and StatefulElement classes. The
TypeMatcher class was also removed.

Migration guide

Code before migration:

ComplexLayoutState

state

context

ancestorStateOfType

const

TypeMatcher

ComplexLayoutState

>())

as

ComplexLayoutState

Code after migration:

ComplexLayoutState

state

context