Home > OS >  The named parameter 'topLeft' isn't defined.- flutter
The named parameter 'topLeft' isn't defined.- flutter

Time:01-26

getting those errors >>

The named parameter 'topLeft' isn't defined.

The named parameter 'topRight' isn't defined.

The getter 'ac_unit' isn't defined for the type 'Icon'.

The getter 'accessibility_new' isn't defined for the type 'Icon'.

The getter 'assesment' isn't defined for the type 'Icon'

The name '_selectedItem' is already defined.

how to correct these errors

enter image description here

void _onButtonPressed() {
    showModalBottomSheet(
        context: context,
        builder: (context) {
          return Container(
                   child:_buildBottomNavigationMenu() ,
            decoration: BoxDecoration(
              color: Theme.of(context).canvasColor,
                topLeft:const Radius.circular(10),
                topRight: const Radius.circular(10)
            ),
          );
        });
  }

      Column _buildBottomNavigationMenu() {
        return Column(
          children: <Widget>[
            ListTile(
              leading: Icon(Icon.ac_unit),
              title: Text('Cooling'),
              onTap: () => _selectedItem,
            ),
            ListTile(
              leading: Icon(Icon.accessibility_new),
              title: Text('People'),
              onTap: () => _selectedItem,
            ),
            ListTile(
              leading: Icon(Icon.assesment),
              title: Text('Status'),
              onTap: () => _selectedItem,
            ),
          ],
        );
      }


  void _selectedItem (String name){
    Navigator.pop(context);
    setState(() {
      _selectedItem = name;
    });
  }


}

CodePudding user response:

This is the correct way to add specific radius in container decoration reference

Container(
          decoration: const BoxDecoration(
            borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(10),
                          topRight: Radius.circular(10),
                        ),
                      ),
          );

Also you added Icon.ac_unit but you should use Icons.ac_unit .

CodePudding user response:

Try this,

void _onButtonPressed() {
    showModalBottomSheet(
        context: context,
        builder: (context) {
          return Container(
                   child:_buildBottomNavigationMenu() ,
            decoration: BoxDecoration(
              color: Theme.of(context).canvasColor,
              borderRadius: BorderRadius.only(  // updated code here
                  topLeft: const Radius.circular(10),
                  topRight: const Radius.circular(10)
                  bottomLeft: Radius.zero,
                  bottomRight: Radius.zero,
    ),
            ),
          );
        });
  }

      Column _buildBottomNavigationMenu() {
        return Column(
          children: <Widget>[
            ListTile(
              leading: Icon(Icons.ac_unit), // updated Icon to Icons
              title: Text('Cooling'),
              onTap: () => _selectedItem,
            ),
            ListTile(
              leading: Icon(Icons.accessibility_new),
              title: Text('People'),
              onTap: () => _selectedItem,
            ),
            ListTile(
              leading: Icon(Icons.assesment),
              title: Text('Status'),
              onTap: () => _selectedItem,
            ),
          ],
        );
      }


  void _selectedItem (String name){
    Navigator.pop(context);
    setState(() {
      _selectedItem = name;
    });
  }


}

CodePudding user response:

That means that property not available for decorationbox widget see here :https://api.flutter.dev/flutter/painting/BoxDecoration-class.html

and for icon it will be Icons.{icon-name}

  •  Tags:  
  • Related