But of course we don't pledge allegiance to the government. Its to the flag that represents the country, and not the government.
Further along those lines, you'll note that soldiers and public officials pledge to uphold the Constitution, they do not pledge loyalty to any government either.
So as long as loyalty the flag doesn't contradict our prior allegiance to God, it is not idolatry though I have heard some people try to say so.
Key concept that people are not getting here.
Flags represent governments. Pledging allegiance to the flag is pledging allegiance to the government, when the fundamental fact of a representative system is that the allegiance is owed the other way around.
The government owes its allegiance to you. NOT vice versa. The Pledge completely inverts the correct and lawful relationship between master (us) and servant (the government) - and this is no accident, given the intent of its author.