Because Avengers: Infinity War and Endgame filmed back-to-back, Brie Larson’s first time playing Carol Danvers was in the Endgame. There wasn’t a script for either Endgame or Captain Marvel at the time, so Larson had to figure out the character from scratch. Luckily, she had the help of the Russo Bros., Boden, and Fleck, which was a prime example of Marvel collaboration, according to Joe Russo.
Article source: https://www.cinemablend.com/news/2470292/the-russo-brothers-worked-with-captain-marvel-team-to-create-brie-larsons-character