多个列表和行-颤振

时间:2020-10-20 03:48:40

标签: flutter

显然,我做错了(根据抖动)

 body:
          ListView.builder(itemBuilder: (context, index){
            return Card(
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Column(
                  children: <Widget>[
                    Text(
                      'Text me'
                    )]
                    )
                )
              ),
            ),
          }),
      Row(
        children: <Widget>[
          Expanded(
            child: new RaisedButton(
              padding: const EdgeInsets.all(8.0),
              textColor: Colors.white,
              color: Colors.blue,
              onPressed: () async { await changestation('http://stream.radiomedia.com.au:8015/stream'); },

              child: new Text("Change Station"),
            ),
          ),
          Expanded(
            child: Text('Craft beautiful UIs', textAlign: TextAlign.center),
          ),
          Expanded(
            child: FittedBox(
              fit: BoxFit.contain, // otherwise the logo will be tiny
              child: const FlutterLogo(),
            ),
          ),
        ],
      ),

我得到的错误是: Too many positional arguments: 0 expected, but 1 found. Try removing the extra positional arguments, or specifying the name for named arguments.

1 个答案:

答案 0 :(得分:1)

您必须将所有内容包装在Column中,然后将ExpandView包装在ListView.builder中。

Column(
         children: [ Expanded(
           child: ListView.builder(itemBuilder: (context, index){
            return Card(
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Column(
                  children: <Widget>[
                    Text(
                      'Text me'
                    )]
                    )
                )
            );
          })),
      Row(
        children: <Widget>[
          Expanded(
            child: new RaisedButton(
              padding: const EdgeInsets.all(8.0),
              textColor: Colors.white,
              color: Colors.blue,
              onPressed: () async {  await changestation('http://stream.radiomedia.com.au:8015/stream'); 
                                   },

              child: new Text("Change Station"),
            ),
          ),
          Expanded(
            child: Text('Craft beautiful UIs', textAlign: TextAlign.center),
          ),
          Expanded(
            child: FittedBox(
              fit: BoxFit.contain, // otherwise the logo will be tiny
              child: const FlutterLogo(),
            ),
          ),
        ],
      ),
                      ])

让我知道是否可行。