Every cellphone has its own pre-installed keyboard, and most vendors have great keyboards. Samsung, for example, has the Microsoft Swype keyboard pre-installed, but on top of that also has a Samsung owned keyboard that works pretty much like the Gboard from Google. Both of these are sending data, your data to Samsung and Microsoft, and possibly also to Google! The same goes, of course, for Gboard from Google, which is found on Pixel phones 'out of the box'.
Gboard is actually the most privacy-friendly keyboard and even though from Google was designed for privacy and security! Yes, I just said that! However...
...with a simple firewall like RethinkDNS, you can block network access to those keyboards.
The main problem here is that all these keyboards collect data, and we kind of get it, it is to "improve the customer experience" via AI learning, yet, it also compromises privacy and scoops up metadata you would want to avoid being shared.
Regardless of which vendor you are on, there will be a keyboard pre-installed. In iOS it's Apple's, so you don't have much choice to get away from it and protect yourself. In Android, on the other hand, you do have options.
Option one, is a firewall. RethinkDNS, AdGuard, and NetGuard can all block internet access to specific apps, including system apps. So if you go down this path, you can use the pre-installed keyboard and have little to worry about. However, if you'd like to get a little more extreme, and be a bit safer than by just blocking network access to your keyboard, you can go with an open-source keyboard.
To do so download F-Droid (which should be the main app shop on an Android phone anyway!).
From here, you have a few excellent options:
An open-source keyboard that does not spy on you! OpenBoard is a 100% FOSS keyboard based on AOSP, with no dependency on Google binaries, that respects your privacy. Features: Spell correction, Themes, Emojis.
OpenBoard comes closed to Gboard from Google, sadly minus the Swype option.
AnySoftKeyboard is an open-source, on-screen keyboard with multiple languages support with an emphasis on privacy. This is one of the most customizable keyboards available. The good news here it has Swype and a hell of a lot more features. It lacks the perfect spellchecker, but you can select system-wide spellcheckers, and combine that with the one from OpenBoard ;)
Open-Source
F-Droid
Highly Recommended
Simply keyboard and nothing more
An open-source keyboard which respects your privacy.
FlorisBoard is still in beta, and I am sure we will see more 'glide to type' languages added in the future. This does not mean FlorisBoard does not support other languages, they do.
You have a clipboard and dictionary built in to FlorisBoard, but can also use the system-wide function of clipboard or the phone dictionary.
These keyboards are all excellent, and most of all they respect your privacy. I prefer AnySoftKeyboard for the simple reason that it has all I am looking for in a keyboard, including glide to type.
Even though these keyboards are open-source, there is no reason they need network access, so remove it and/or block it if you want to put your phone's most dangerous 'secret agent' into lockdown!
Most people do not think about their keyboard, but if your texts get into an AI system for Microsoft, Samsung, Google, and the like, then there is a good chance your metadata, and perhaps even everything you type, is with them too, whether you like it or not!