formLayout.getChildren().forEach() throws nullPointerException


I trying to construct my form by adding controls dynamically, and i can confirm that the controls are added in FormLayout because of the responsive effect of the layout when i adjust the window size.

FormLayout formLayout = new FormLayout();
formLayout.add(new TextField());
Stream<Component> children = formLayout.getChildren();

children.forEach(control->{ ← throws nullPointerException at this line, even though the children variable is not null.