Flutter:如何使其可滚动

时间:2019-09-09 13:45:44

标签: flutter containers

嗨,这是我的第一个Flutter应用,我在使容器可滚动时遇到了一个小问题。

我想知道我需要添加什么才能使其成为可能?

    double c_width = MediaQuery.of(context).size.width;

return new Container (
  padding: const EdgeInsets.all(16.0),
  width: c_width,
  child: new Column (
    children: <Widget>[
            Row(
            children: <Widget>[
              new Text('DRN',style: TextStyle(color: Colors.black, fontSize: 20.0),),
               new Text('1', style: TextStyle(color: Colors.red, fontSize: 20.0),),
               new Text(': The Sound Of Indie',style: TextStyle(color: Colors.black, fontSize: 20.0),)

            ],
      ),
      Column (
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(8.0),
            child: Text ("When it comes to listening to music in this digital world there are so many ways to do it, either via YouTube, iTunes, Spotify, Google Music or the old fashioned Radio, where you get the commercial artists forced at you over and over again.", textAlign: TextAlign.left),
          ),
          Padding(
            padding: EdgeInsets.all(8.0),
            child: Text ("DRN1 is different. We are proud to show real talent, and artists that listeners may never of heard before but will quickly fall in love with. Sure, the music might not get publicised by major labels, and may not have the budget to get old styled radio stations playing. But, why should music come down to how much money you can throw at an artist just to hope that the listeners will end up buying said track or album?", textAlign: TextAlign.left),
          ),
      ],
      ),
      Row(
      children: <Widget>[
            new Text('The Sound of ',style: TextStyle(color: Colors.black, fontSize: 20.0),),
            new Text('Life', style: TextStyle(color: Colors.red, fontSize: 20.0),),

          ],
      ),
      Column (
          children: <Widget>[
            Padding(
             padding: EdgeInsets.all(8.0),
                  child: Text ("When it comes to listening to music in this digital world there are so many ways to do it, either via YouTube, iTunes, Spotify, Google Music or the old fashioned Radio, where you get the commercial artists forced at you over and over again.", textAlign: TextAlign.left),
      ),
              Padding(
                  padding: EdgeInsets.all(8.0),
                    child: Text ("DRN1 is different. We are proud to show real talent, and artists that listeners may never of heard before but will quickly fall in love with. Sure, the music might not get publicised by major labels, and may not have the budget to get old styled radio stations playing. But, why should music come down to how much money you can throw at an artist just to hope that the listeners will end up buying said track or album?", textAlign: TextAlign.left),
              ),
          ],
      ),
      Row(
        children: <Widget>[
          new Text('The Sound of ',style: TextStyle(color: Colors.black, fontSize: 20.0),),
          new Text('Life', style: TextStyle(color: Colors.red, fontSize: 20.0),),

        ],
      ),
      Column (
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(8.0),
            child: Text ("When it comes to listening to music in this digital world there are so many ways to do it, either via YouTube, iTunes, Spotify, Google Music or the old fashioned Radio, where you get the commercial artists forced at you over and over again.", textAlign: TextAlign.left),
          ),
          Padding(
            padding: EdgeInsets.all(8.0),
            child: Text ("DRN1 is different. We are proud to show real talent, and artists that listeners may never of heard before but will quickly fall in love with. Sure, the music might not get publicised by major labels, and may not have the budget to get old styled radio stations playing. But, why should music come down to how much money you can throw at an artist just to hope that the listeners will end up buying said track or album?", textAlign: TextAlign.left),
          ),
        ],
      ),

    ],
  ),
);

2 个答案:

答案 0 :(得分:0)

您可以将容器嵌套在ListViewSingleChildScrollView

答案 1 :(得分:0)

您可以使用SingleChildScrollView小部件:

return new Container (
  padding: const EdgeInsets.all(16.0),
  width: c_width,
  child: new SingleChildScrollView(
    child: new Column (
      children: <Widget>[
            Row(
            children: <Widget>[
              new Text('DRN',style: TextStyle(color: Colors.black, fontSize: 20.0),),
               new Text('1', style: TextStyle(color: Colors.red, fontSize: 20.0),),
               new Text(': The Sound Of Indie',style: TextStyle(color: Colors.black, fontSize: 20.0),)

            ],
      ),
....

您可以在以下链接中找到所有滚动小部件:

https://flutter.dev/docs/development/ui/widgets/scrolling