Flutter: Могу ли я добавить строку заголовка в ListView

Это известная проблема, и одно возможное решение предоставляется drop.levels() в пакете gdata , где ваш пример становится

> drop.levels(subdf)
  letters numbers
1       a       1
2       b       2
3       c       3
> levels(drop.levels(subdf)$letters)
[1] "a" "b" "c"

Существует также dropUnusedLevels в пакете Hmisc . Однако он работает только путем изменения оператора подмножества [ и здесь неприменим.

В качестве следствия прямой подход на основе столбца является простым as.factor(as.character(data)):

> levels(subdf$letters)
[1] "a" "b" "c" "d" "e"
> subdf$letters <- as.factor(as.character(subdf$letters))
> levels(subdf$letters)
[1] "a" "b" "c"

22
задан davidk 23 April 2018 в 16:59
поделиться

2 ответа

1. you can add container and lisview in Column ,

import 'package:flutter/material.dart';

void main() => runApp(MyApp());


class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

класс _MyAppState расширяет состояние {

@override
void initState() {



  // TODO: implement initState
  super.initState();
 }

 @override
 Widget build(BuildContext context) {
  return MaterialApp(
  debugShowCheckedModeBanner: false,
   home: Scaffold(
    appBar: AppBar(
      title: Text("Demo App1"),
    ),
    body: Column(
      children: <Widget>[
        Container(
          height: 40.0,
          child: Row(
            children: <Widget>[
              Container(
                padding: EdgeInsets.all(4.0),
              width: 100.0
              ,child: Text("Name",style: TextStyle(fontSize: 18),)),
              Container(
                  padding: EdgeInsets.all(4.0),
                  width: 100.0
                  ,child: Text("Age",style: TextStyle(fontSize: 18),)),
            ],
          ),
        ),
        Expanded(
          child: ListView.builder(
          itemCount: 100
          ,itemBuilder: (BuildContext context,int index){
            return Row(
              children: <Widget>[
                Container(
                    padding: EdgeInsets.all(4.0),
                    width: 100.0
                    ,child: Text("Name $index",
                style:TextStyle(fontSize:18),)),
                Container(
                    padding: EdgeInsets.all(4.0),
                    width: 100.0
                    ,child: Text("Age $index",
                style: TextStyle(fontSize: 18),))
              ],
            );
          }),
        )
        ],
       ),
       ),
      );
     }
    }
1
ответ дан 28 November 2019 в 23:25
поделиться

Можно добавить столбец к первому объекту в списке объекта как это

new ListView.builder
  (
    itemCount: litems.length,
    itemBuilder: (BuildContext ctxt, int index) {
     if(index==0)
{
return
Column(
children: <Widget>[
Header();
rowContent(index);
]
else{
return rowContent(index);
}
    }
  )
0
ответ дан 28 November 2019 в 23:25
поделиться
Другие вопросы по тегам:

Похожие вопросы: