I finally figured it out, albeit I’m not sure why what I did worked. I ended up solving this by temporarily commenting out retrofit in the main project pubspec.yaml and building the project.
After this build it did not matter whether retrofit was included or commented out anymore in the pubspec.yaml of the main project.