Check if element is child of another in Dart


I need to check if a clicked element is child of another, using jQuery I would do: $('#foo').length === 1 but with dart I have no clue.

void main(){
   (querySelector('body') as BodyElement).onClick.listen(onGlobalClick);

onGlobalClick(Event event){
 Element element =;
 //Check if `element` is child of an element with an id of 'foo'



should return whether is a descendant of element

Answered By – Günter Zöchbauer

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *