颤振 - 键盘在屏幕上浮动FloatingActionButton

问题描述:

我正在使用TextField但键盘提高FloatingActionButton。我想知道键盘是否可以不提高FloatingActionButton?根据下面的gif,在下面的代码中,我以两种不同的方式放置了两个FloatingActionButton,但是在两个键盘都向上的情况下,由于FAB与TextField位于同一行,因此妨碍了字段填充。颤振 - 键盘在屏幕上浮动FloatingActionButton

有什么办法解决这个问题吗?

enter image description here

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), 
    ), 
    ); 
    } 
} 

它看起来像你正在设计一个全屏幕的对话框。

浮动操作按钮表示应用程序中的主要操作,如创建新项目。这不是您用来确认更改并关闭包含文本字段列表的全屏对话框。

不是使用FloatingActionButton,我会一个在actions插槽建议用FlatButtonAppBar,就像这个Material design example

save

你可以看到如何建立一个全的例子Flutter中的屏幕对话框在Gallery source code中。

+0

谢谢,我理解Material Design的概念,但为了探索Flutter,我意识到Stack和Positioned将会一直上升。为了解决问题,我使用列重建了代码,并且它仅在将MainAxisAlignment:MainAxisAlignment.spaceBetween的SingleChildScrollView属性放置时才起作用,它将停止工作。所以我打开另一个问题https://*.com/questions/45982176/flutter-singlechildscrollview-interfering-in-columns – rafaelcb21