Can't generate RealmModel

Hi, I’m trying to generate a new RealmModel.

I put in a simple model and when I run ‘flutter pub run realm generate’ I get the following error:

[SEVERE] Unhandled build failure!
Invalid argument(s): name shouldn’t end with a ‘.’
[SEVERE] Failed after 13.6s
pub finished with exit code 1

Ran on: M1 Macbook | Flutter 3.7.3 | Dart 2.19.2 | realm ^1.0.1
What I’ve done:

  • Restart the terminal
  • Restart the computer
  • Update Flutter and Dart to the latest one (Flutter 3.7.3, Dart 2.19.2)
  • Started new Flutter project and put same car.dart in the project and it generated successfully

Repro Steps

  1. Add the code snippet below (car.dart) to a flutter project
  2. Run flutter pub run realm generate
  3. I get an error `pub finished with exit code 1

Code Snippet
/lib/models/car.dart

import 'package:realm/realm.dart';

part 'car.g.dart';

@RealmModel()
class _Car {
  late String make;

  late String model;

  int? kilometers = 500;
}

Hi,
we could not reproduce the problem. For example adding this model in this sample we are able to generate the Realm models correctly realm-dart-samples/provider_shopper at main · realm/realm-dart-samples · GitHub

Are you adding this model to a a brand new flutter project or an existing one? In such case it might help if you do run flutter pub run realm generate --clean command first.
If this is a brand new project then could you run flutter pub deps and send the output here so we can see what dependencies this project has?

cheers

Hi,

Thanks for the quick reply. I started eliminating directories and individual files from the project until I found the offending file. It turns out one of the files had two periods in the file name (‘permission_handler…dart’). I never noticed this since the Flutter project still compiles. After taking out one period the RealmModel generated successfully.

I suggest that the Realm generator should account for this.

Regards,

Alvin

Hi,you talking about,[quote=“Alvin_Chan, post:3, topic:213646”]
Thanks for the quick reply. I started eliminating directories and individual files from the project until I found the offending file. It turns out one of the files had two periods in the file name (‘permission_handler…dart’).
[/quote].you have to search on google.

Cristiano Ronaldo`s inspirational story