skip to Main Content

I don’t understand why this property is getting error.. I’ve checked flutter doc and it should be working fine. Anyone could help?

When I hover it: The named parameter ‘labelWidget’ isn’t defined.
Try correcting the name to an existing named parameter’s name, or defining a named parameter with the name ‘labelWidget’

enter image description here

    import 'package:flutter/material.dart';

/*-------Lista apenas de exemplo para o dropdown das malhas-------*/

enum MalhaLabel {
  malha1('010 dime: omissão de entrega'),
  malha2('NF-e: Cálculo: '),
  malha3('NF-e: Cálculo:'),
  malha4(
      'NF-e: Cálculo2: omissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entrega'),
  malha5(
      'NF-e: Cálculo2: omissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entregaomissão de entrega');

  const MalhaLabel(this.label);
  final String label;
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final TextEditingController malhaController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
        preferredSize: const Size.fromHeight(70.0),

        /*-------AppBar com título-------*/

        child: AppBar(
          titleSpacing: 0.00,
          leading: Builder(
            builder: (BuildContext context) {
              return IconButton(
                onPressed: () {
                  Scaffold.of(context).openDrawer();
                },
                icon: const Icon(Icons.filter_alt_outlined),
              );
            },
          ),
          title: const Text(
            'AUDITORIA | MALHAS FISCAIS',
            style: TextStyle(
              color: Colors.white,
              fontSize: 18,
              fontWeight: FontWeight.bold,
            ),
          ),
          backgroundColor: const Color(0xFF1C5D22),
        ),
      ),

      /*-------Drawer com filtros-------*/
      drawer: Container(
        width: 350,
        child: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: [
              const SizedBox(
                height: 90.0,
                child: DrawerHeader(
                  decoration: BoxDecoration(
                    color: Color(0xFF1C5D22),
                  ),
                  child: Row(
                    children: [
                      Icon(
                        Icons.filter_alt_outlined,
                        color: Colors.white,
                      ),
                      SizedBox(
                        width: 16,
                      ),
                      Text(
                        'FILTROS',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ],
                  ),
                ),
              ),

              /*-------Filtros-------*/

              Padding(
                padding: const EdgeInsets.only(bottom: 20, top: 20),
                child: ListTile(
                  title: const Text(
                    'Malhas fiscais:',
                    style: TextStyle(fontSize: 16),
                  ),
                  subtitle: Padding(
                    padding: const EdgeInsets.only(top: 8),
                    child: DropdownMenu<MalhaLabel>(
                      controller: malhaController,
                      enableFilter: true,
                      requestFocusOnTap: true,
                      hintText: 'Digite e selecione',
                      dropdownMenuEntries:
                          MalhaLabel.values.map<DropdownMenuEntry<MalhaLabel>>(
                        (MalhaLabel malha) {
                          return DropdownMenuEntry<MalhaLabel>(
                            value: malha,
                            labelWidget: SizedBox(
                              width: MediaQuery.of(context).size.width * 0.90,
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Text(
                                  malha.label,
                                ),
                              ),
                            ),
                            label: malha.label,
                          );
                        },
                      ).toList(),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

2

Answers


  1. Chosen as BEST ANSWER

    Solved, my flutter was outdated...


  2. You are probably on an old version of Flutter.

    labelWidget was probably added after Flutter v2.5 upgrade to the latest and it should fix your issue

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search