I'm trying to use the ChoiceChip
widget in a Cupertino App.
I found this solution https://github.com/flutter/flutter/issues/21872#issuecomment-421508939 on GitHub
CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
title: 'Flutter Demo',
home: new MyHomePage(title: 'Flutter Demo Home Page'),
)
Here is my code
return CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate,
],
home: CupertinoStoreHomePage(),
);
_buildChoiceList() {
List<Widget> choices = List();
widget.reportList.forEach((item) {
choices.add(Container(
child: ChoiceChip(
label: Text(item),
selected: selectedChoice == item,
onSelected: (selected) {
setState(() {
selectedChoice = item;
widget.onChoiceSelected(item);
});
},
),
));
});
return choices;
}
and I get this error
════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown building ChoiceChip(dirty): No Material widget found.
ChoiceChip widgets require a Material widget ancestor.