Flutter DropdownButton() 问题

Flutter DropdownButton() issue

我的 DropdownButton() 在 flutter 中有问题,它给了我这个错误。我不知道这里出了什么问题....

Couldn't infer type parameter 'T'.
Tried to infer 'dynamic' for 'T' which doesn't work:
Parameter 'onChanged' declared as     'void Function(T?)?'
                    but argument is 'void Function(Object?)'.
The type 'dynamic' was inferred from:
Parameter 'items' declared as     'List<DropdownMenuItem<T>>?'
                but argument is 'List<DropdownMenuItem<dynamic>>'.

Consider passing explicit type argument(s) to the generic.

这是我的 DropdownButton 代码片段。

DropdownButton(
                    items: [
                      DropdownMenuItem(
                        child: Text(
                          'Solar System',
                          style: TextStyle(
                            fontFamily: 'Avenir',
                            fontSize: 24,
                            color: const Color(0x7cdbf1ff),
                            fontWeight: FontWeight.w500,
                          ),
                          textAlign: TextAlign.left,
                        ),
                      ),
                    ],
                    onChanged: (value) {},
                    icon: Padding(
                      padding: const EdgeInsets.only(left: 16.0),
                      child: Image.asset('assets/drop_down_icon.png'),
                    ),
                    underline: SizedBox(),
                  ),

您必须在 DropdownButtonDropdownMenuItem

旁边指定类型 <String>
DropdownButton<String>(
 items: [
  DropdownMenuItem<String>(
   child: Text(
    'Solar System',
    style: TextStyle(
     fontFamily: 'Avenir',
     fontSize: 24,
     color: const Color(0x7cdbf1ff),
     fontWeight: FontWeight.w500,
    ),
    textAlign: TextAlign.left,
   ),
  ),
 ],
 onChanged: (value) {},
 icon: Padding(
  padding: const EdgeInsets.only(left: 16.0),
  child: Image.asset('assets/drop_down_icon.png'),
 ),
 underline: SizedBox(),
),