Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-generate class is not updating with build_runner

I am using a build_runner to generate auto-generated code in the flutter project.

Issue: When I make an update in the model class and then I try to run below command, but it does not update auto-generated class.

Command:

pub run build_runner build

Dart Packages:

built_value: '>=5.5.5 <7.0.0'

build_runner: ^1.5.0

built_value_generator: ^6.6.0

After the execution of the command for build_runner, an auto-generated class should be updated.

like image 460
Shakti S.P. Swain Avatar asked Jul 24 '19 06:07

Shakti S.P. Swain


2 Answers

When it conflicts with current generated classes, it may possible that it will not update the generated classes. So I have tested with below command and it's working fine.

flutter packages pub run build_runner build --delete-conflicting-outputs

This will delete current conflict files and recreate as per the requirements.

like image 186
Jigar Avatar answered Oct 02 '22 16:10

Jigar


You need to use the watch sub-command to Continuous generation of code.

flutter packages pub run build_runner watch

It runs a persistent build server that watches the files system for edits and does rebuilds as necessary.

like image 25
ibhavikmakwana Avatar answered Oct 02 '22 15:10

ibhavikmakwana