#flutter #dart #drop-down-menu #dropdown
Вопрос:
I want to any way set Full Width 100% in dart/flutter. but it is not set in dropdown list in flutter. my source code below in details.
Container( height: 50, width: 500.0, // width: MediaQuery.of(context).size.width, child: Expanded( child: DropdownButtonHideUnderline( child: ButtonTheme( alignedDropdown: true, child: DropdownButton( isExpanded: true, value: _selectionRetailer, style: Theme.of(context).textTheme.bodyText1, // items: mRetailList.map((index) { items: mRouteWiseRetailList.map((index) { return DropdownMenuItem( alignment: Alignment.center, child: new Text( index.retailerTitle "_" index.retailerAddress, style: TextStyle(fontSize: 10), ), value: index.retailerID, ); }).toList(), onChanged: (sal) { setState(() { mRetailer = sal; _selectionRetailer = sal; retailerID = sal; print("SAVEDATADD" "retailerID: $retailerID"); if (reasonID == "0") { } else { startTime = Fhelper.CurrentDateTime(); Fhelper.showToast( "RetailerID: $retailerID, StartTime: $startTime, salesOfficerID: $salesOfficerID"); print("SAVEDATADD" "RetailerID: $retailerID, StartTime: $startTime, salesOfficerID: $salesOfficerID,entryBy : $entryBy"); clearAll(); } }); }, ), ), ), ), ),
как достичь этой полной ширины в раскрывающемся списке в flutter.
Ответ №1:
Удалите Expanded
и Container
и следуйте приведенному ниже коду
DropdownButtonHideUnderline( child: ButtonTheme( alignedDropdown: true, child: DropdownButton( isExpanded: true, value: dropdownvalue, icon: Icon(Icons.keyboard_arrow_down), items:items.map((String items) { return DropdownMenuItem( value: items, child: Text(items) ); } ).toList(), onChanged: (String newValue){ setState(() { dropdownvalue = newValue; }); }, ), ), )