Skip to content

Instantly share code, notes, and snippets.

@VB10
Created April 20, 2023 00:42
Show Gist options
  • Save VB10/9ba7ea032e2c58a5826ca3c93c86d7e5 to your computer and use it in GitHub Desktop.
Save VB10/9ba7ea032e2c58a5826ca3c93c86d7e5 to your computer and use it in GitHub Desktop.
Use case login view
class _LoginViewState extends State<LoginView> with LoginController {
late final ClearTextAction textAction;
late final ControllerCleaner _controllerCleaner;
String _value = '';
@override
void initState() {
super.initState();
textAction = ClearTextAction();
_controllerCleaner = ControllerCleaner(textAction);
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: Row(
mainAxisSize: MainAxisSize.min,
children: [
_homeButton(),
_removeButton(),
],
),
appBar: AppBar(),
body: _CustomTextField(
action: textAction,
onChange: (String value) {
_value = value;
},
));
}
FloatingActionButton _homeButton() {
return FloatingActionButton.large(
child: const Icon(Icons.home),
onPressed: () {
_controllerCleaner.update('home');
},
);
}
FloatingActionButton _removeButton() {
return FloatingActionButton(
child: const Icon(Icons.remove),
onPressed: () {
_controllerCleaner.clear();
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment