[flutter_tool] Refactor Logger and Terminal to (mostly) no longer depend directly on context (#47269)