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

[Flutter] Dart macros error "The part-of directive must be the only directive in a part."

Discussão em 'Mobile' iniciado por Stack, Novembro 5, 2024 às 12:22.

  1. Stack

    Stack Membro Participativo

    I'm trying to use an experimental feature from Dart called macros.

    For now, there's a limited support from IDEs (The only way to show the augmented classes/methods is in VSCode) and it's required to use the Flutter beta channel.

    What I've got so far:

    • A custom working Macro
    • An augmented class with the desired code

    However, theres a problem with the imports section in the augmented file.

    The fully generated code:

    part of 'package:macros_test/home_module.dart';

    import 'dart:core' as prefix0; // SHOWS ERROR
    import 'package:flutter_modular/src/presenter/models/bind.dart' as prefix1; // SHOWS ERROR

    augment class HomeModule {
    augment prefix0.List<prefix1.Bind> get binds {
    return [...augmented];}
    }


    The analyzer shows me this error for both imports


    The part-of directive must be the only directive in a part. Try removing the other directives, or moving them to the library for which this is a part.dart(non_part_of_directive_in_part)

    Anybody knows what's going on here?

    Continue reading...

Compartilhe esta Página