1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How to add conditional imports across Flutter mobile,web and window?

Discussão em 'Mobile' iniciado por Stack, Novembro 8, 2024 às 04:02.

  1. Stack

    Stack Membro Participativo

    I have flutter application which uses different webview plugin for each platform(mobile, web, window).
    Though I am able to import platform base on web and mobile, I am not able to import for windows.

    I have tried adding else condition if it is not mobile or web, but it is taking mobile plugin.

    1. This is how I import package for web and mobile (Working).

    import 'package:eam_flutter/form/mobileui.dart'
    if (dart.library.html) 'package:eam_flutter/form/webui.dart'
    as multiPlatform;

    1. This is how I import package for web, mobile and windows (Not Working, it is showing mobile webview exception since it doesn't support desktop).

    import 'package:eam_flutter/form/windowui.dart'
    if (dart.library.html) 'package:eam_flutter/form/webui.dart'
    if (dart.library.io) 'package:eam_flutter/form/mobileui.dart'
    as multiPlatform;


    How can I specify conditional imports for windows?

    Continue reading...

Compartilhe esta Página