gbtb16 / kiwi

A simple compile-time dependency injection library for Dart and Flutter
MIT License
351 stars 51 forks source link

It is not generating anything #91

Open kristijorgji opened 8 months ago

kristijorgji commented 8 months ago

I am using

  build_runner: ^2.4.7
  kiwi_generator: ^4.1.0

and do run flutter packages pub run build_runner build

My /lib/di/core/injector.dart is

import 'package:dl_mobile_flutter/app/app_config.dart';
import 'package:kiwi/kiwi.dart';

part 'injector.g.dart';

const keyApiUrl = 'apiUrl';

abstract class Injector {
  void configure();

  void production();

  void development();

  static void inject(AppConfig config) {
    var injector = _$Injector()..configure();

    if (config.isProduction) {
      injector.production();
    } else if (config.isDevelopment) {
      injector.development();
    }
    KiwiContainer().registerInstance(config.baseUrl, name: keyApiUrl);
  }
}

T inject<T>([String? name]) => KiwiContainer().resolve<T>(name);

After running build_runner no injector.g.dart is created

gbtb16 commented 8 months ago

Hi, @kristijorgji!

Thank you for contributing to the development of Kiwi. I appreciate the information about the issue you're facing.

I believe it's a known issue, and possibly dependencies in kiwi_generator that have not been updated to the minimum versions.

I ask that you wait for the new release tag to test again to see if your problem still occurs.

Also, if you have any other questions, don't hesitate to send them here. 😄