Hi I am trying this piece of code and whenever I try to open and select something from the menù I get this error:
Exception has occurred.
_AssertionError ('package:flutter/src/rendering/object.dart': Failed assertion: line 3345 pos 14: 'renderer.parent != null': is not true.)
This is where I copied and pasted the code:
class test extends StatefulWidget{
const test({super.key, required this.title});
final String title;
@override
State<test> createState() => _testState();
}
const List<String> list = <String>['One', 'Two', 'Three', 'Four'];
class _testState extends State<test>{
String dropdownValue = list.first;
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
//...
),
SliverFillRemaining(
child: Align(
alignment: Alignment.center,
//2 SingleChildScrollView one with Axis.vertical and another one with Axis.horizontal
//column
//inside the column this:
DropdownMenu<String>(
initialSelection: list.first,
onSelected: (String? value) {
setState(() {
dropdownValue = value!;
});
},
dropdownMenuEntries:
list.map<DropdownMenuEntry<String>>((String value) {
return DropdownMenuEntry<String>(value: value, label: value);
}).toList(),
);
)
)
]
)
)
);
}
}
I tried to delete the 2 SingleChildScrollView
and everything works but I need them in order to not get an overflowed bottom since I have inside the column other elements beside this DropDownMenu
. What can I do?