"flutter dropdownbuttonformfield initial value" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "flutter dropdownbuttonformfield initial value" answered properly. Developers are finding an appropriate answer about flutter dropdownbuttonformfield initial value related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like flutter dropdownbuttonformfield initial value. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on flutter dropdownbuttonformfield initial value.
flutter dropdownbuttonformfield initial value
import 'package:flutter/material.dart';
import '../config/app_theme.dart';
class DropdownWidget extends StatefulWidget {
final String title;
final List<String> items;
final ValueChanged<String> itemCallBack;
final String currentItem;
final String hintText;
DropdownWidget({
this.title,
this.items,
this.itemCallBack,
this.currentItem,
this.hintText,
});
@override
State<StatefulWidget> createState() => _DropdownState(currentItem);
}
class _DropdownState extends State<DropdownWidget> {
List<DropdownMenuItem<String>> dropDownItems = [];
String currentItem;
AppTheme appTheme;
_DropdownState(this.currentItem);
@override
void initState() {
super.initState();
for (String item in widget.items) {
dropDownItems.add(DropdownMenuItem(
value: item,
child: Text(
item,
style: TextStyle(
fontSize: 16,
),
),
));
}
}
@override
void didUpdateWidget(DropdownWidget oldWidget) {
if (this.currentItem != widget.currentItem) {
setState(() {
this.currentItem = widget.currentItem;
});
}
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
appTheme = AppTheme(Theme.of(context).brightness);
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 6),
child: Text(
widget.title,
style: appTheme.activityAddPageTextStyle,
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.white,
boxShadow: [
BoxShadow(
offset: Offset(0, 2),
blurRadius: 10,
color: Color(0x19000000),
),
],
),
child: DropdownButtonHideUnderline(
child: DropdownButton(
icon: appTheme.activityAddPageDownArrowSVG,
value: currentItem,
isExpanded: true,
items: dropDownItems,
onChanged: (selectedItem) => setState(() {
currentItem = selectedItem;
widget.itemCallBack(currentItem);
}),
hint: Container(
child: Text(widget.hintText, style: appTheme.hintStyle),
),
),
),
),
],
),
);
}
}
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on flutter dropdownbuttonformfield initial value can get a collection of related answers to their query. Programmers need to enter their query on flutter dropdownbuttonformfield initial value related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about flutter dropdownbuttonformfield initial value for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of flutter dropdownbuttonformfield initial value while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "flutter dropdownbuttonformfield initial value". Visit this developer's friendly online web community, CodeProZone, and get your queries like flutter dropdownbuttonformfield initial value resolved professionally and stay updated to the latest Whatever updates.