Screen Width

Hello,

How can I get the screen width? (Vaadin 14)

I tried with:

UI.getCurrent().getInternals().getExtendedClientDetails().getScreenWidth();

But I’m getting a NPE.

Thanks,

Claudio

You can use the extended client details like this:

        UI.getCurrent().getPage().retrieveExtendedClientDetails(receiver -> {
            int screenWidth = receiver.getScreenWidth();
            // do something with screen width
        });

Thanks Olli!