On Flutter 3.0.5 TargetPlatform enum doesn’t have a value for web platform.

Theme.of(context).platform is used for adapting UI to different platforms, but for web platform you can’t use it (on TargetPlatform enum doesn’t exist web) and must use the kIsWeb global variable.

This package contains the enum UITargetPlatform, that has the same values than TargetPlatform with a new value web.

It also contains the global variable debugDefaultUITargetPlatformIsWeb for testing. The package test_screen uses it for doing web tests.


Get TargetPlatform from Theme and pass it to UITargetPlatform.fromTargetPlatform().

  Widget build(BuildContext context) {
    final platform =
    switch (platform) {
      case UITargetPlatform.iOS:
        return _cupertinoSlider();
      case UITargetPlatform.web:
        return _webSlider();
        return _defaultSlider();


View Github

Entradas similares

Deja una respuesta