Skip to content

Instantly share code, notes, and snippets.

@rei-codes
Created April 28, 2023 14:23
Show Gist options
  • Save rei-codes/b2d5bcde0e4268a2e3a135ee876edb70 to your computer and use it in GitHub Desktop.
Save rei-codes/b2d5bcde0e4268a2e3a135ee876edb70 to your computer and use it in GitHub Desktop.
Next focus on enter
class NextFocusOnEnter extends StatelessWidget {
const NextFocusOnEnter({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Next focus on enter'),
),
body: Column(
children: const [
Padding(
padding: EdgeInsets.all(16),
child: TextField(
decoration: InputDecoration(hintText: 'First'),
// Magic happens here
// Switches the focus to the next widget
textInputAction: TextInputAction.next,
),
),
Padding(
padding: EdgeInsets.all(16),
child: TextField(
decoration: InputDecoration(hintText: 'Second'),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment