4
我正在使用TextField
但鍵盤提高FloatingActionButton
。我想知道鍵盤是否可以不提高FloatingActionButton
?根據下面的gif,在下面的代碼中,我以兩種不同的方式放置了兩個FloatingActionButton
,但是在兩個鍵盤都向上的情況下,由於FAB與TextField
位於同一行,因此妨礙了字段填充。顫振 - 鍵盤在屏幕上浮動FloatingActionButton
有什麼辦法解決這個問題嗎?
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
final ui.Size logicalSize = MediaQuery.of(context).size;
final double _width = logicalSize.width;
return new Scaffold(
appBar: new AppBar(backgroundColor: new Color(0xFF26C6DA)),
body: new Stack(
children: <Widget>[
new ListView(
children: <Widget>[
new TextField(
decoration: const InputDecoration(
labelText: "Description",
),
style: Theme.of(context).textTheme.title,
),
new TextField(
decoration: const InputDecoration(
labelText: "Description",
),
style: Theme.of(context).textTheme.title,
),
new TextField(
decoration: const InputDecoration(
labelText: "Description",
),
style: Theme.of(context).textTheme.title,
),
],
),
new Positioned(
bottom: 16.0,
left: (_width/2) - 28,
child: new FloatingActionButton(
backgroundColor: new Color(0xFFE57373),
child: new Icon(Icons.check),
onPressed:(){}
),
)
],
),
floatingActionButton: new FloatingActionButton(
backgroundColor: new Color(0xFFE57373),
child: new Icon(Icons.check),
),
);
}
}
謝謝,我理解Material Design的概念,但爲了探索Flutter,我意識到Stack和Positioned將會一直上升。爲了解決問題,我使用列重建了代碼,並且它僅在將MainAxisAlignment:MainAxisAlignment.spaceBetween的SingleChildScrollView屬性放置時才起作用,它將停止工作。所以我打開另一個問題https://stackoverflow.com/questions/45982176/flutter-singlechildscrollview-interfering-in-columns – rafaelcb21