dart_mappable icon indicating copy to clipboard operation
dart_mappable copied to clipboard

[Bug] 2.0.0-dev.5: Mappable tries to import deleted files

Open lucavenir opened this issue 3 years ago • 0 comments

Hi there again!

Try the following steps with 2.0.0-dev.5:

  1. Define an abstract class and a concrete subclass of such class
// asd.dart
import 'package:dart_mappable/dart_mappable.dart';

import '../main.mapper.g.dart';

@MappableClass()
abstract class Asd with AsdMappable {
  const Asd(this.id);

  final String id;
}

@MappableClass()
class Something extends Asd with SomethingMappable {
  const Something(super.id);
}
  1. Import this file in your main.dart file and generate code with build_runner watch. Everything works fine.
  2. DELETE the file you've just created (asd.dart) and delete its import in the main file
  3. The import of asd.dart still persists in main.mapper.g.dart, and it doesn't go away in the next code generations

It's really hard to make this broken import go away, and it does only after certain conditions, which I'm unsure of at this moment in time. The only reliable way to force a full reset of the generated code is to interrupt watch, perform a pub get and then watch again

lucavenir avatar Oct 31 '22 10:10 lucavenir