-1

I want to build a Screen in Flutter which should look like this:

--BEGIN Important Part--

  1. Generated Columnitems (containing heading and description)
  2. List of items

--END Important Part--

How can I generate those Columns (which not should be scollable) in combination with a following Listview? How can I generate "no Listview"-Widgets like n ListView? How to build Columns like building a ListView?

1 Answers1

0

Your question is quite confusing. Is this what you are looking for?

import 'package:flutter/material.dart';

main()  {
  runApp(new MaterialApp(
    title: 'Flutter Example',
    home: new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(title: new Text("Flutter Example"),),
        body: new MyApp(),
      ),
    ),
  ));
}

class MyApp extends StatelessWidget {


  @override
  Widget build(BuildContext context) {

    List<ColumnItem> items = [];

    // creates ColumnItems to display
    for (var i = 0; i < 40; i++) {
      items.add(
        new ColumnItem(title: "This is a title", description: "Descriptions are usefull",)
      );
    }

    return new ListView(
      children: items,
    );
  }
}




class ColumnItem extends StatelessWidget {

  final String title;
  final String description;

  const ColumnItem({this.title, this.description});

  @override
  Widget build(BuildContext context) {
    return new Column(
      children: <Widget>[
        new Text(this.title, style: new TextStyle(fontSize: 22.0, fontWeight: FontWeight.bold),),
        new Text(this.description)
      ],
    );
  }
}

Edit: Upon further reading your question, maybe this is what you are trying to do?

import 'package:flutter/material.dart';

main()  {
  runApp(new MaterialApp(
    title: 'Flutter Example',
    home: new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(title: new Text("Flutter Example"),),
        body: new MyApp(),
      ),
    ),
  ));
}

class MyApp extends StatelessWidget {


  @override
  Widget build(BuildContext context) {

    List<ColumnItem> items = [];

    // creates ColumnItems to display
    for (var i = 0; i < 40; i++) {
      items.add(
        new ColumnItem(title: "This is a title", description: "Descriptions are usefull",)
      );
    }

    return new Column(
      children: [
        new Text("Static Title", style: new TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold), ),
        new Text("This is a static desctription"),
        new Divider(),
        new Expanded(
          child: new ListView(children: items) ,
        )

      ],
    );
  }
}




class ColumnItem extends StatelessWidget {

  final String title;
  final String description;

  const ColumnItem({this.title, this.description});

  @override
  Widget build(BuildContext context) {
    return new Column(
      children: <Widget>[
        new Text(this.title, style: new TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold),),
        new Text(this.description)
      ],
    );
  }
}
Mans
  • 2,953
  • 2
  • 23
  • 32