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

[Flutter] How to access a hierarch dart class attribute?

Discussão em 'Mobile' iniciado por Stack, Outubro 15, 2024 às 20:22.

  1. Stack

    Stack Membro Participativo

    How can I manage image paths for different categories, like logos and backgrounds, in Dart? I tried using nested classes like in Java, but Dart doesn't support that! What are the best practices or alternatives to handle this?


    void main() {
    print(Images.background.lake); // it dosn't work!
    }

    class Images {
    class Portrait {
    final traditional = 'assets/images/portrait/traditional.png';
    final environmental = 'assets/images/portrait/environmental.png';
    }

    class Background {
    final nature = 'assets/images/background/nature.png';
    final lake = 'assets/images/background/lake.png';
    }
    }

    Continue reading...

Compartilhe esta Página