firstByType<T extends Widget> method
Returns the first mounted element whose widget type is T, or null.
Implementation
Element? firstByType<T extends Widget>() {
final matches = byType<T>();
return matches.isEmpty ? null : matches.first;
}