尽管SingleChildScrollView颤振溢出异常

时间:2018-07-14 11:53:42

标签: flutter flutter-layout

我下面有一个Textfield包裹着一个Chips和一个Wrap列表。
Textfieldactive并弹出键盘时,在底部与包装的Chips重叠的键盘底部出现溢出异常。

我认为将Wrap放在SingleChildScrollView中可以解决此问题,但是由于某些原因却不能解决问题?
我在这里想念什么?

import 'package:flutter/material.dart';

class ScrollableTest extends StatelessWidget {

final List<String> _items = ['item1', 'item2', 'item3', 'item4', 'item5', 
                           'item6', 'item7', 'item8', 'item9', 'item10'];

@override
Widget build(BuildContext context) {
return new Scaffold(
  appBar: new AppBar(
    title: new Text('Scroll Test'),
  ),
  body: new Container(
    padding: EdgeInsets.all(25.0),
    child: new Center(
      child: new Column(
        children: <Widget>[
          new Padding(
            padding: EdgeInsets.only(bottom: 20.0),
            child: new Column(
              children: <Widget>[
                new Text('Foo',
                  style: new TextStyle(fontSize: 20.0,),
                  textAlign: TextAlign.center,
                ),
                new Padding(
                  padding: EdgeInsets.only(top: 10.0),
                ),
                new Text('bar',
                  textAlign: TextAlign.center,
                  style: new TextStyle(color: Colors.black54),
                )
              ],
            )
          ),
          new Container(
            child:new TextField(
              autofocus: false,
              onChanged: (text) { },
            ),
          ),
          new SingleChildScrollView(
            child: new Container(
              padding: EdgeInsets.only(top: 100.0),
              child: new Wrap(
                alignment: WrapAlignment.center,
                spacing: 5.0,
                runSpacing: 10.0,
                children: _items.map((a) => new Chip(label: new Text(a))).toList()
              ),
            )
          )
        ]
      )
    )
  )
);
}
}

0 个答案:

没有答案