title: Flutter: DropdownButton<BankAccountDTO> widgets require a Material widget ancestor
body: <p>I'm trying to build a drop down menu in flutter and I keep getting the following error:</p>
  <p>The following assertion was thrown building DropdownButton(dirty, state: _DropdownButtonState#b71c7):
  No Material widget found.</p>
  <p>DropdownButton widgets require a Material widget ancestor.</p>
  <p>I'm fairly new to flutter and this is my code, currently I can see the drop down menu and select an account but yet I keep getting this error! Any help is appreciated</p>
  <pre><code>    @override
    Widget build(BuildContext context) {
  return Column(children: &lt;Widget&gt;[
    Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: &lt;Widget&gt;[
          SizedBox(
            width: 60,
          ),
          Column(
            children: &lt;Widget&gt;[
              Container(
                height: 5,
              ),
              Container(
                  margin: EdgeInsets.only(top: 15.0),
                  child: Column(
                    children: &lt;Widget&gt;[
  
                      Text(
                        'Select Account',
                      ),
                    ],
                  )),
            ],
          ),
          SizedBox(
            width: 60,
            height: 60,
          ),
        ]),
    Expanded(
        child: Center(
            child: _isLoading
                ? SpinKitFadingCircle(
              size: 50.0,
            )
                : KeyboardAvoider(
              duration: Duration(milliseconds: 0),
              child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: &lt;Widget&gt;[
                    Column(children: &lt;Widget&gt;[
  
                    ]),
  
                    Container(),
                    Column(children: &lt;Widget&gt;[
  
                      Text(
                        'Select account\n',),
                      Theme(
                        data: Theme.of(context).copyWith(
                          canvasColor: StateContainer
                              .of(context)
                              .curTheme
                              .background,
                        ),
                        child: DropdownButton(  // this is the drop down button causing error
                          value: (StateContainer
                              .of(context)
                              ?.bankAccounts
                              ?.values
                              ?.toList() ??
                              [])
                              .contains(_selectedAccount)
                              ? _selectedAccount
                              : (StateContainer
                              .of(context)
                              ?.bankAccounts
                              ?.length ??
                              0) &gt;
                              0
                              ? StateContainer
                              .of(context)
                              ?.bankAccounts
                              ?.values
                              ?.first
                              : null,
                          icon: Icon(Icons.arrow_downward),
                          iconSize: 24,
                          elevation: 16,
                          underline: Container(
                            height: 2,
                            color: StateContainer
                                .of(context)
                                .curTheme
                                .primary,
                          ),
                          onChanged: (BankAccountDTO newValue) {
                            setState(() {
                              _selectedAccount = newValue;
  
                            });
                          },
                          items: StateContainer
                              .of(context)
                              ?.bankAccounts
                              ?.values
                              ?.map((BankAccountDTO bankAccountDTO) {
                            return DropdownMenuItem(
                              value: bankAccountDTO,
                              child: Text('${bankAccountDTO.type} ' +
                                  '(...${bankAccountDTO.accountNumber
                                      .substring(
                                      bankAccountDTO.accountNumber.length -
                                          4)}) ' +
                                  '\$${bankAccountDTO.balance.toStringAsFixed(
                                      2)}'),
                            );
                          })?.toList(),
                        ),
                      )
  
                    ])
                  ]),
            ))),
  </code></pre>