I've been seeing a lot of posts recently on several different subreddits related to the difficulties of writing gender, particularly women. It's very easy to find yourself in the same pitfalls that so many other writers do, making women either 2-dimentional with no agency, or so stereotypically defiant of gender norms to the point that it's boring. As a young writer who cares deeply about fair representation of gender, writing a flat, uninteresting, inconsequential female character is among my very worst fears. The best way I've found to come at the problem is simply this: figure out the role a character plays and elements of their intersectionality that have little to do with gender (where they're from, what their job is, family history, etc). Then flip a coin on their gender and let that element of intersectionality fill out the space it needs in who they are. It shouldn't be vital to their character unless the experience of gender is an important element in your story. Otherwise, it's better to let other elements of a character's life and role define them more than their gender. You're likely to have a much more interesting cast of characters if you flip a coin for the genders of at least half of them. It allows you to focus on all the elements that define them that aren't gender, and therefore helps flesh them out. It's also a great way to accidentally find yourself writing some great scenes between female characters and pass the bechdel test with flying colors.
Note: I'm not the most experienced writer, and on top of that I'm male, but this approach has been working wonders for me. Not only has it led to the creation of some very interesting characters (and therefore more fulfilling stories), it's also helped me change my approach when I already DO know a character's gender when I flesh them out. It's good practice in exploring personhood. I hope it's helpful to you!
Edit: To be clear, this is not a universal tool. It's an exercise that gets you to take on a different approach that helps flesh out characters that could otherwise end up devoid of depth. Personally I've found it far more useful for supporting characters than leading ones. Sometimes you need to know your character's gender at inception, sometimes you end up changing it halfway through writing the story. In the end it's still your story, still your character, and whatever works, works.