If you're running that version of Gboard, you should go digging in the app's settings under Preferences and scroll down to the Layout subsection. A new toggle should be waiting for you there: Switch to dark theme in battery saver. Like its name clearly explains, when your phone's battery saver mode is on, Gboard will automatically turn to a dark theme. I tried testing this in WhatsApp, but the theme switch wouldn't get triggered reliably there, though in other apps it does. After battery saver is enabled, you just have to collapse the keyboard and re-open it, and ta-da, dark theme. Disable the battery saver and Gboard switches back to the light theme.
This is a welcome change, but I can't help but wonder why such a setting is only reliant on battery saver. What about the night light/grayscale modes? Or the Device theme setting in Android Pie? If I'm turning down for the night and avoiding distractions and harsh light, a dark keyboard would certainly make a lot more sense than a white one. Just like it would make sense if I've picked a dark theme for my launcher. Google has machine learning algorithms for much more complex things, it befuddles me that simple deduction features like this are still not baked into the Android operating system.
To check out the new automatic dark theme switch, you can grab Gboard 7.6.13 from the Play Store or on APK Mirror.