GetIt Register Object

Hi all,

Why when I register an object like Dio as factory, I get same hashcodes for any object like the below:

getIt.registerFactory(() => dio);

final dio1 = getIt();
final dio2 = getIt();

logger.d(‘Dio1 hashcode: ${dio1.hashCode}’);
logger.d(‘Dio2 hashcode: ${dio2.hashCode}’);

Result are:

I/flutter (10155): │ :bug: Dio1 hashcode: 297846279

I/flutter (10155): │ :bug: Dio2 hashcode: 297846279

@escamoteur

Appreciate your help :slight_smile:

No wonder, shouldn’t it be () => dio() otherwise you return the address of the constructor which will be te same always?