我当时正在使用Stack
小部件来覆盖google_maps_flutter
和TextField
。但是,当我专注于TextField
且键盘输入弹出时,Google Maps
似乎会变小。
我尝试用SingleChildScrollView
小部件包装以忽略调整大小,但是在实现它时给了我错误。
class _DashboardState extends State<Dashboard> {
// Google maps
Completer<GoogleMapController> _controller = Completer();
// remove this and use gps system instead
CameraPosition _initialPosition =
CameraPosition(target: LatLng(26.8206, 30.8025));
final String tagLineFamily = 'Gafata';
final Color _baseColor = Color.fromRGBO(101, 200, 208, 1.0);
final Color _darkBlue = Color.fromRGBO(44, 88, 113, 1.0);
// search text controller
var _searchText = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
_ayudaMap(),
_appBar(),
],
),
);
}
Widget _appBar() {
return SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
child: Container(
height: 120,
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
_baseColor,
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
boxShadow: [BoxShadow(color: Colors.transparent)],
),
child: Center(
child: _searchTextField(),
),
),
);
}
Widget _searchTextField() {
return Container(
padding: EdgeInsets.only(left: 10, right: 10),
alignment: Alignment.center,
height: 40,
width: MediaQuery.of(context).size.width / 1.5,
decoration: BoxDecoration(
color: _baseColor.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
border: Border.all(
width: 2.0,
color: _darkBlue,
),
),
child: TextField(
cursorColor: _darkBlue,
style: TextStyle(
fontFamily: tagLineFamily,
fontSize: 14,
color: _darkBlue,
fontWeight: FontWeight.w600,
),
controller: _searchText,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Need Assistance? Find here!',
hintStyle: TextStyle(
color: _darkBlue,
),
icon: Icon(
Icons.search,
color: _darkBlue,
),
),
),
);
}
Widget _ayudaMap() {
return GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: _initialPosition,
);
}
// Google Maps controller
void _onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
}
}
我想要实现的是在键盘输入弹出时忽略调整大小。
答案 0 :(得分:1)
尝试编辑支架以包括此参数
resizeToAvoidBottomPadding : false,