how to create a row of scrollable text boxes or widgets in flutter inside a ListView?

前端 未结 6 1089
悲哀的现实
悲哀的现实 2021-01-01 11:46

1.Please, can someone tell me how to create a row of text boxes that are scrollable to left or right in flutter inside a ListView. I can see that I am trying to define an in

6条回答
  •  不思量自难忘°
    2021-01-01 11:56

    I think this is straightforward as long as you put a container of fixed height on your horizontal ListView. But maybe I'm not understanding your question. Please post your code and the error message you're getting if this doesn't work.

    import 'package:flutter/material.dart';
    import 'package:flutter/gestures.dart';
    import 'dart:collection';
    
    void main() {
      runApp(new MaterialApp(home: new DemoApp()));
    }
    
    class DemoApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          appBar: new AppBar(title: new Text('Nested ListView Example')),
          body: new Center(
            child: new ListView(
              children: [
                new Container(
                  height: 80.0,
                  child: new ListView(
                    scrollDirection: Axis.horizontal,
                    children: new List.generate(10, (int index) {
                      return new Card(
                        color: Colors.blue[index * 100],
                        child: new Container(
                          width: 50.0,
                          height: 50.0,
                          child: new Text("$index"),
                        ),
                      );
                    }),
                  ),
                ),
              ],
            ),
          ),
        );
      }
    }
    

提交回复
热议问题