3

I'm trying to create a package for Flutter that provides source generation using source_gen. I would like to be able to annotate a class and fields to identify what needs to be generated. (An example of this would be the libraries Dagger2 or ROOM, for java.)

Given an abstract class:

@ServiceCalls("http://www.whocares.com")
abstract class ServiceCalls 
    @Get
    int getCount();
    @Post
    void postCount(int count);
}

The following concrete implementation would be generated:

class ServiceCallsImp extends ServiceCalls {
    Future<int> getCount() {
        // details for implementing a get service call
    }

    Future<void> postCount(int count) {
        // details for implementing a post call
    }
}

So, the big questions I'm trying to answer are: 1) Is an abstract class the way to go, or is a part the correct approach? 2) How do I setup builders for a 'recursive' annotation processing? (Annotated fields in an annotated class)

NOTE: I don't really care about service calls, its just an example.

eimmer
  • 1,537
  • 1
  • 10
  • 29

0 Answers0