Too many positional argument on ListView

111

It seems you put the ListView.Builder() and GestureDetector() into Column() widget incorrectly.

Here is a correct sample:

Column(
   children:[
       ListView.Builder(),
       GestureDetector(),
   ],
)

When adding values for Column() and Row() you will need to add it into the children: property.

Share:
111
Kyuhan Nam
Author by

Kyuhan Nam

Updated on December 19, 2022

Comments

  • Kyuhan Nam
    Kyuhan Nam over 1 year

    I'm writing the test code of the ListView. Though I specified the name of parameters explicitly, I got the error message, 'Too many positional arguments: 0 expected, but 2 found'. Any suggestion to solve this?

    Thanks in advance.

    @override
      Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBar(
              title: const Text('File Example'),
            ),
            body: Center(
                child: Column(
                    ListView.builder(
                        itemCount: (this.ideaCount == null) ? 0 : this.ideaCount,
                        itemBuilder: (BuildContext context, int position) {
                          return Card(
                            color: Colors.white,
                            elevation: 2.0,
                            child: ListTile(
                              title: Text(ideaList[position].name),
                              subtitle: Text(ideaList[position].memo),
                            )
                          );
                        }),
                    GestureDetector(
                        onLongPress: () async {
                          print("Long Press");
                          result = await record.hasPermission();
                          if (result) {
                            var dir = await getApplicationDocumentsDirectory();
                            print("############");
                            print(dir.path);
                            DateTime now = DateTime.now();
                            recordDate = '$now';
                            await record.start(
                              path: dir.path + recordDate! + '.aac',
                              encoder: AudioEncoder.AAC,
                              bitRate: 128000,
                              samplingRate: 44100,
                            );
                          } else {
                            print('##########Not Allowed!!!!!');
                          }
                        },
                        onLongPressUp: () async {
                          print("Long Press Stop");
                          record.stop();
                          Idea idea = Idea(1, recordDate!, 'test');
                          helper.insertIdea(idea);
                          setState(() {
                            showData();
                          });
                        },
                        child: ElevatedButton(
                            onPressed: () {}, child: Icon(Icons.mic))))));
      }
    
  • Kyuhan Nam
    Kyuhan Nam about 2 years
    Oh... I see. It was not ListView issue, but Column issue. I'll try that. Thank you very much!