2017-08-14 10 views
2

Flutter Appの簡単なログインページを作成しようとしています。私はTextFieldsとLogin/Signinボタンを作成しました。私は水平ListViewを追加したい。私のコードを実行すると、私の要素が消えてしまいます。もしListViewを使わなければ、もう一度やり直してください。どうやってこれを正しく行うことができますか?Flutterの列にListViewを追加する方法?

return new MaterialApp(
     home: new Scaffold(
      appBar: new AppBar(
      title: new Text("Login/Signup"), 
     ), 
      body: new Container(
      child: new Center(
       child: new Column(
       mainAxisAlignment: MainAxisAlignment.center, 
       children: <Widget>[ 
        new TextField(
        decoration: new InputDecoration(
         hintText: "E M A I L A D D R E S S" 
        ), 
       ), 
        new Padding(padding: new EdgeInsets.all(15.00)), 
        new TextField(obscureText: true, 
        decoration: new InputDecoration(
         hintText: "P A S S W O R D" 
        ), 
        ), 
        new Padding(padding: new EdgeInsets.all(15.00)), 
        new TextField(decoration: new InputDecoration(
        hintText: "U S E R N A M E" 
       ),), 
        new RaisedButton(onPressed: null, 
        child: new Text("SIGNUP"),), 
        new Padding(padding: new EdgeInsets.all(15.00)), 
        new RaisedButton(onPressed: null, 
        child: new Text("LOGIN"),), 
        new Padding(padding: new EdgeInsets.all(15.00)), 
        new ListView(scrollDirection: Axis.horizontal, 
        children: <Widget>[ 
        new RaisedButton(onPressed: null, 
        child: new Text("Facebook"),), 
        new Padding(padding: new EdgeInsets.all(5.00)), 
        new RaisedButton(onPressed: null, 
        child: new Text("Google"),) 
        ],) 

       ], 
      ), 
      ), 
      margin: new EdgeInsets.all(15.00), 
     ), 
     ), 
    ); 

答えて

3

コンソール出力を確認できます。

The following assertion was thrown during performResize(): Horizontal viewport was given unbounded height. Viewports expand in the cross axis to fill their container and constrain their children to match their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of vertical space in which to expand.

水平リストに高さの制約を追加する必要があります。例えば。

new Container(
    height: 44.0, 
    child: new ListView(
    scrollDirection: Axis.horizontal, 
    children: <Widget>[ 
     new RaisedButton(
     onPressed: null, 
     child: new Text("Facebook"), 
    ), 
     new Padding(padding: new EdgeInsets.all(5.00)), 
     new RaisedButton(
     onPressed: null, 
     child: new Text("Google"), 
    ) 
    ], 
), 
) 
+0

ありがとうございます。私はIntelliJでビルドしていたプラグインを追加しており、デバッグはコンソールには印刷されません。あなたがこれを修正する方法を知っているなら、私に@Mogolを知らせてください –

0

私は水平リストビューの答えを見つけました。 new Rowを列ウィジェットとして使用します。行はチュートリアルで頻繁に言及されていないクラスであり、ここに見つけることができますhttps://docs.flutter.io/flutter/widgets/Row-class.html

関連する問題