BURBANK, Calif. — Grandma is mad. Her grown daughter, Bex, who got pregnant as a teenager, just blazed back into town and let a big secret slip. Grandma had raised 13-year-old Andi to believe that Bex was her older sister. Well, the truth is a tad more complicated.

Meanwhile, Andi’s school life is only a little less unsettling. A boy is coming to terms with his sexuality. And Andi has her own budding love life to consider.

The latest from MTV?

Hang on to your mouse ears: Disney Channel — land of safe, sweet sitcoms — is exploring this charged terrain with “Andi Mack,” a comedic drama aimed at children 6 to 14 and their parents.

While it is just one show, it represents a startling new direction for the squeaky-clean network, whose ratings are decaying as children, reaching puberty earlier and raised on the oh-so-cool Netflix, gravitate to live-action programming with more edge and authenticity.

“I know I can’t go to the hugely dramatic space,” said Gary Marsh, president of Disney Channels Worldwide. “I can’t go to the sexual space. I can’t go horror. Where can I go that would elevate the content and get people talking about us in a way that is different from the way they talk about us normally?”

Sitting in his office here, amid mementos from glory-days hits like “High School Musical,” Mr. Marsh mused about breakthrough shows for adults like “Orange Is the New Black” on Netflix and “The Walking Dead” on AMC.

“There has to be an equivalent in our space,” he said. “Stories that matter, that deal with more complex issues, that are emotional, resonate longer. They stick to your guts.”

Whether “Andi Mack” connects with viewers when it makes its premiere on April 7 is anyone’s guess. (Disney Channel released the first two episodes on its digital platforms on Friday to spread word of mouth.) But Mr. Marsh’s willingness to even take the risk is revealing: As storytelling tastes change and viewing habits shift, the predictable formulas are no longer enough.

Andi Mack (Full Episode) | Andi Mack | Disney Channel
Video by disneychannel

The internet has created more curious and progressive kids. That has led to what the industry calls “age compression” — getting older younger. At the same time, Netflix in many ways has become the go-to outlet for families. YouTube has also had an enormous impact.

If you are a 12-year-old girl, why watch “Liv and Maddie,” a Disney Channel sitcom, when you can go to YouTube and watch someone who seems just like you and may even respond if you send her a message?

Disney Channel ratings have been sinking. In February, according to Nielsen data, standard viewership was down 18 percent among children 2 to 11 from the same period in 2016 — even as the rival Nickelodeon held steady. (Unlike the animation-heavy Nickelodeon, Disney Channel does not sell traditional ads, so ratings matter less. But it does sell sponsorships, and needs to keep viewership high to justify the fees it charges cable distributors.)

Wall Street has started to notice, increasing the pressure to find a new hit. On Disney’s most recent conference call with industry analysts, Robert A. Iger, Disney’s chief executive, blamed lower ratings on “a proliferation of kids programming” (Netflix) and “a bit of an off cycle” at Disney Channel itself.

“We think that the ratings are likely to improve with the addition of some new shows that we think creatively are very strong,” Mr. Iger said.

“Andi Mack” got its start in 2015, when Mr. Marsh asked a television writer named Terri Minsky to have breakfast. If anyone could help Disney Channel step in a bold, new direction, Mr. Marsh had decided, it was her. In 2001, Ms. Minsky helped a then-struggling Disney Channel find its voice by creating the hit sitcom “Lizzie McGuire.” The network began pumping out comedies in its blindingly polished likeness, to enormous success.

But Ms. Minsky, whose other credits include “Sex and the City,” was not keen to create a show with child actors.

“I really didn’t want to ever write for kids again because I do feel like it interrupts their development,” she said. “There are certainly examples of people who have gone off the rails.” (Amanda Bynes. Miley Cyrus. Mary-Kate Olsen. Vanessa Hudgens. Zac Efron. Demi Lovato. Britney Spears. Lindsay Lohan.)

Still, Ms. Minsky said that something Mr. Marsh had told her at breakfast was intriguing. “He said, ‘We’re kind of looking to do something different — we feel like ABC Family has abdicated that market for teenagers, and there is an opportunity for us,’” Ms. Minsky recalled.

ABC Family, a Disney-owned channel aimed at viewers 18 to 34, was radically rebranded as Freeform in 2015. Ratings have dropped sharply since.

Emboldened by Mr. Marsh’s entreaty, Ms. Minsky pitched an idea she got while reading an article about Jack Nicholson’s life; the woman he thought was his sister (until he was nearly 40) was his mother. To Ms. Minsky’s shock, Mr. Marsh liked the concept. It was a self-discovery story that, in success, could appeal to both children and their parents.

For the crucial lead role, Ms. Minsky cast the newcomer Peyton Elizabeth Lee. Aside from her presence on camera, Ms. Minsky liked that the young actress did not look as if she had fallen off a child-star assembly line: Ms. Lee, who is of mixed ethnicity, has short hair and a crooked grin. “Disney was, like, ‘Should we grow her hair out?’ And I was, like, ‘No!’” Ms. Minsky recalled.

“Andi Mack” stands out for more than its subject matter. Scenes were shot outside. Sets were built to look like the real world. (Andi does not have an impossibly bedazzled bedroom.) Story lines play out over a full season. The characters, not the situation, are meant to be compelling.

Mr. Marsh emphasized that “Andi Mack” was written in a “relatable, respectful and age-appropriate way.” Consultants from the National Campaign to Prevent Teen and Unplanned Pregnancy and the National Center on Adoption and Permanency were hired to help Ms. Minsky navigate the family-twist drama. The advisers emphasized “taking responsibility for choices” and “the enormous responsibilities of a parent or guardian,” a Disney Channel spokeswoman, Patti McTeague, wrote in an email.

In other words, “Andi Mack” broadens the Disney concept, but only to a degree. “If the brand is a circle, put your pivot foot in the center of the circle, take your other foot and stretch it as far as you can go,” Mr. Marsh said. “As long as you don’t let go of your pivot foot, you will be safe.”

Correction: March 11, 2017

An earlier version of this article omitted part of the name of an organization that was hired to consult on “Andi Mack.” It is the National Campaign to Prevent Teen and Unplanned Pregnancy, not the National Campaign to Prevent Teen Pregnancy.