Oakland is the eighth-largest city in California and one of the most ignored by the movie industry. Until recently, anyway. Now the rapidly gentrifying city is getting a reputation as a prime location for films made by and about people of color.

Natives have used it to frame social-issue drama (Ryan Coogler’s emotionally devastating, fact-based “Fruitvale Station”), superhero spectacle (Coogler again, in Marvel’s “Black Panther”) and surreal comedy (Boots Riley’s workplace fantasy “Sorry to Bother You”).

Oakland is a main character in “Blindspotting,” a wildly entertaining dramatic comedy about the intersection of race, class and love that opened Friday. Daveed Diggs, who won a Grammy Award and a Tony Award as a star of the smash Broadway musical “Hamilton,” co-wrote and co-stars in “Blindspotting” with his longtime friend and artistic collaborator Rafael Casal, who has joined him as a lyricist and vocalist on several self-produced rap albums.

While Diggs is at a point in his career where he could take any number of roles, he chose to make his screenwriting debut on a project he had been developing for a decade. He plays Collin, an amiable furniture mover carefully passing a year on probation following a fairly minor crime that mushroomed into a felony conviction. Casal plays his devoted friend and moving partner Miles, a white homeboy who wears gold fittings over his bottom teeth just for show and has stood up for Collin no matter what. Their warm friendship is beginning to fray, however. Miles’ thuggish mannerisms threaten to draw Collin into a confrontation with the police.

Diggs and Casal wrote the first version of the script 10 years ago. Casal, in a joint phone conversation, said it ultimately needed what he termed “a massive overhaul” that eventually became a complete rewrite just three weeks before filming began.

“It was a mess. A lot of good ideas, but really messy,” Diggs said. “He would call me and say, ‘Here’s what I want to do,’ and I would say, ‘Here’s the 10 problems I have with that, but go ahead.’ I was skeptical, but it was so much better than the one we had been working on for 10 years. It was an idea that never went away despite the false starts and all the time that passed. It’s something I have been working on with my best friend forever.”

“Hamilton,” in which he played the dual roles of Thomas Jefferson and the Marquis de Lafayette, gave him a chance to demonstrate his versatility.

“The nice thing about ‘Hamilton’ is that it didn’t push me in one direction. It sort of allowed me to walk into spaces and people would be like, ‘Well, what do you want to do?’ ”

“Blindspotting” makes the changing landscape of the city a cornerstone of its story.

“It used to be a much blacker town,” Diggs said. “I think the more interesting and more complicated observation is that the cost of living has skyrocketed as it has everywhere in the country, and at an even more rapid rate in the Bay Area. What happened in San Francisco was so staggering, the cost of living went up so fast, that people who would be wealthy by any other standards got pushed out and came flocking over to Oakland. It’s unsustainable. The amount of wealth that exists in the Bay Area is incredibly high. But so is the level of poverty and the function of gentrification on the vanishing middle class.”

His father, a bus driver born and raised in Oakland, moved away because he couldn’t afford to live there. When longtime residents are forced out, the history, the culture and the character that made the place attractive are lost, as well, he said. “That’s a scary thing.”

Casal said the goal of shooting in their old neighborhoods was to create “a true representation of the community that these characters came out of. That was fundamentally important to us. I know those people. I’m familiar with the experience of being immersed in communities of color. Much of the film is a composite of stories and experiences that either we experienced or friends of ours or people in our community experienced.”

That shaped the film in fundamental ways. Every scene has a friend or a family member of the team, a rapper or a spoken word poet from the area, to say two words of dialogue or walk across the camera. There also are personal experiences. In one scene, Wayne Knight, who plays a photographer packing up his exhibit for shipping, says of two portraits, “Oh, don’t have Santiago and Dante facing each other; they don’t get along.” “That’s my dad and his dad,” Casal said.

“There’s a lot of improv,” he added, “a lot of ad-libbing going on. Mostly on my part out of fear of messing up. Daveed and I have been working together for so long. Because of that relationship we can riff for a while, and for a few moments we got lucky and some really powerful stuff came out.”

In the film, Diggs, whose résumé includes turns playing charming characters in the 2017 film “Wonder” and the TV series “Unbreakable Kimmy Schmidt,” mixes that good-humored tone with a ferocious outburst of uncontrollable anger. He said that having the chance to come close to violence was part of what inspired him to create the movie.

“It was hard for me. But it is what you live for as an actor: to work on projects where you get to use every part of yourself, you know? All of the things that you’re good and bad at. You don’t get so many opportunities to do that, so when you write it for yourself, you do it. It was a dream gig, you know? Just as an actor, I’m glad I got the part.”