In AGOL when you are adding layers to your webmap you can click on the triple ellipses next to the layer and choose "Hide in Legend". This is currently the only option.
OK I have figured this out but will need more info from you to provide code and where you should put the code.
It is actually quite simple you just need to obtain an instance of the layer that you want to hide from the Legend and the Layer List widget and assign this:
layer._basemapGalleryLayerType = 'reference';
but what I need to know is:
Thank you so much with the help
1. The layer is coming from a webmap. When I do hide the sub-layers in Portal, they do not hide when I open WAB.
2. I want it hidden at startup
"The layer is coming from a webmap. When I do hide the sub-layers in Portal, they do not hide when I open WAB."
I would like to know what version of WAB you found this problem. That is a bug of DevelopVsersion 1.0 and PortalVersion 10.3, bug that bug had fixed in DevelopVsersion 1.1 and PortalVersion 10.3.1.