Mobx does not generate Dart file.

Asked

Viewed 102 times

-2

Hello, recently my project from scratch simply started not generating the file .g.Dart when I import some class in the model, even the classes that were already imported if I leave it error and does not generate the file.

In a totally weird way, the only mistake that gets me back when running the app is this:

lib/mobx/nomeModel.dart:5:6: Error: Can't use 'lib/mobx/nomeModel.g.dart' as a part, because it has no 'part of' declaration.
part 'nomeModel.g.dart';

lib/mobx/nomeModel.dart:7:41: Error: Type '_$nomeModel' not found.
class nomeModel= _nomeModel with _$nomeModel;
                                        ^^^^^^^^^^^^^^

Has anyone ever had this problem or knows how to fix it?

  • Are you missing declare the part of from your store, which is responsible for creating the arquiovo g.dart... Only with this you showed us can not answer you anything useful. Here on package have an example.

1 answer

0

The name of the file g.Dart usually leave with lowercase letter, because it will be the name of the file to be generated, differentiating the names is also a good, for example:

import 'package:mobx/mobx.dart';
part 'nomemodel.g.dart';

class NomeModel = NomeModelStore with _$NomeModel;

abstract class NomeModelStore with Store {
 
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.