Hide FAB when onscreen keyboard appear
up vote
4
down vote
favorite
In Flutter, how to make FAB button hide when onscreen keyboard appear?
FAB button cover up other element when on screenkeyboard show up.
material-design flutter fab
add a comment |
up vote
4
down vote
favorite
In Flutter, how to make FAB button hide when onscreen keyboard appear?
FAB button cover up other element when on screenkeyboard show up.
material-design flutter fab
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
In Flutter, how to make FAB button hide when onscreen keyboard appear?
FAB button cover up other element when on screenkeyboard show up.
material-design flutter fab
In Flutter, how to make FAB button hide when onscreen keyboard appear?
FAB button cover up other element when on screenkeyboard show up.
material-design flutter fab
material-design flutter fab
asked Jan 19 at 9:02
Kyaw Tun
6,36611946
6,36611946
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
7
down vote
accepted
You can achieve it by checking for keyboard visibility using viewInsets
and hide fab based on it.
Example:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: "Example",
home: new FabHideOnKeyboard(),
));
}
class FabHideOnKeyboard extends StatefulWidget {
@override
_FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState();
}
class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> {
@override
Widget build(BuildContext context) {
final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0;
return Scaffold(
resizeToAvoidBottomPadding: true,
body:Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("TextField:"),
TextField()
],
),
),
floatingActionButton: showFab?Icon(Icons.add):null,
);
}
}
Hope that helped!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
You can achieve it by checking for keyboard visibility using viewInsets
and hide fab based on it.
Example:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: "Example",
home: new FabHideOnKeyboard(),
));
}
class FabHideOnKeyboard extends StatefulWidget {
@override
_FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState();
}
class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> {
@override
Widget build(BuildContext context) {
final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0;
return Scaffold(
resizeToAvoidBottomPadding: true,
body:Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("TextField:"),
TextField()
],
),
),
floatingActionButton: showFab?Icon(Icons.add):null,
);
}
}
Hope that helped!
add a comment |
up vote
7
down vote
accepted
You can achieve it by checking for keyboard visibility using viewInsets
and hide fab based on it.
Example:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: "Example",
home: new FabHideOnKeyboard(),
));
}
class FabHideOnKeyboard extends StatefulWidget {
@override
_FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState();
}
class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> {
@override
Widget build(BuildContext context) {
final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0;
return Scaffold(
resizeToAvoidBottomPadding: true,
body:Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("TextField:"),
TextField()
],
),
),
floatingActionButton: showFab?Icon(Icons.add):null,
);
}
}
Hope that helped!
add a comment |
up vote
7
down vote
accepted
up vote
7
down vote
accepted
You can achieve it by checking for keyboard visibility using viewInsets
and hide fab based on it.
Example:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: "Example",
home: new FabHideOnKeyboard(),
));
}
class FabHideOnKeyboard extends StatefulWidget {
@override
_FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState();
}
class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> {
@override
Widget build(BuildContext context) {
final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0;
return Scaffold(
resizeToAvoidBottomPadding: true,
body:Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("TextField:"),
TextField()
],
),
),
floatingActionButton: showFab?Icon(Icons.add):null,
);
}
}
Hope that helped!
You can achieve it by checking for keyboard visibility using viewInsets
and hide fab based on it.
Example:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: "Example",
home: new FabHideOnKeyboard(),
));
}
class FabHideOnKeyboard extends StatefulWidget {
@override
_FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState();
}
class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> {
@override
Widget build(BuildContext context) {
final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0;
return Scaffold(
resizeToAvoidBottomPadding: true,
body:Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("TextField:"),
TextField()
],
),
),
floatingActionButton: showFab?Icon(Icons.add):null,
);
}
}
Hope that helped!
edited Nov 11 at 10:43
Community♦
11
11
answered Jan 22 at 13:23
Hemanth Raj
3,8671127
3,8671127
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48337422%2fhide-fab-when-onscreen-keyboard-appear%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown