Notes
![]() ![]() Notes - notes.io |
class DropDown extends StatefulWidget {
const DropDown({Key key}) : super(key: key);
@override
_DropDownState createState() => _DropDownState();
}
class _DropDownState extends State<DropDown> {
int index;
var _fileTypes2 = ["India", "Canada", "America"];
var _currentSelectedValue2;
var _currentSelectedValue3;
CustomLoader customLoader = new CustomLoader();
List<Result> countryList = [];
List<States> stateList = [];
CountryListDataModel countryListDataModel =new CountryListDataModel();
@override
void initState() {
// TODO: implement initState
super.initState();
countryApiCall();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appBar(),
body: container(
widget: Center(
child: column(),
),
),
);
}
Column column() {
return Column(
children: [
textFieldDropdown(),
(stateList?.length??0)>0?textFieldDropdown1():Container(child: Text("Data Not Found"),),
sizeBox(height: height_50),
_currentSelectedValue2==null?Text("country"):
Text("Country Name:${_currentSelectedValue2}"),
Text("State Name:${_currentSelectedValue3}")
],
);
}
TextFieldDropdown textFieldDropdown() {
return TextFieldDropdown(
hint: "Countries Name",
iconMargin: margin_10,
items: countryList.map((Result value) {
return DropdownMenuItem<String>(
value: value.name,
child: Text(value.name,style: textStyle(color: black),),
);
}).toList(),
value: _currentSelectedValue2,
onChanged: (newValue) {
setState(() {
_currentSelectedValue2 = newValue;
index = countryList.indexWhere((setData) =>
setData.name == _currentSelectedValue2);
stateList=countryList[index].states;
});
},
);
}
TextFieldDropdown textFieldDropdown1() {
return TextFieldDropdown(
hint: "States Name",
iconMargin: margin_10,
items: stateList.map((States value) {
return DropdownMenuItem<String>(
value: value.name,
child: Text(value.name,style: textStyle(color: black),),
);
}).toList(),
value: _currentSelectedValue3,
onChanged: (newValue) {
setState(() {
_currentSelectedValue3 = newValue;
});
},
);
}
AppBar appBar() {
return AppBar(
title: Text('Country Lists'),
);
}
countryApiCall() async {
debugPrint("API Worked");
await APIRepository().countryApi().then((value) {
debugPrint("API is Working");
customLoader.show(context);
if (value != null) {
debugPrint("API Worked $value");
customLoader.hide();
countryListDataModel = value;
countryList=countryListDataModel.result;
setState(() {
});
}
}).onError((error, stackTrace) {
toast(message: error.toString());
customLoader.hide();
});
}
}
Future countryApi() async {
try {
final response =
await dioClient.get("https://api.printful.com/countries");
return CountryListDataModel.fromJson(response);
}
catch (e) {
return Future.error(NetworkExceptions.getDioException(e));
}
}
import 'package:flutter/material.dart';
import '../constants/dimens.dart';
import '../utility/helper_utility.dart';
class TextFieldDropdown extends StatelessWidget {
final String hint;
final Function validate;
final FocusNode focusNode;
final String icon;
final String suffixIcon;
final double width;
final double height;
final double iconMargin;
final items;
final Function onChanged;
final value;
const TextFieldDropdown({
this.hint,
this.iconMargin = 10,
this.icon,
this.width,
this.height,
this.validate,
this.focusNode,
this.suffixIcon,
this.items,
this.onChanged,
this.value,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: DropdownButtonHideUnderline(
child: DropdownButtonFormField(
hint: Text(
hint,
style: textStyle(color: Colors.grey),
),
icon: Icon(
Icons.arrow_drop_down,
size: 30,
),
focusNode: focusNode,
style: textStyle(
color: Colors.black, fontsize:font_14),
validator: validate,
decoration: new InputDecoration(
hintText: hint,
hintStyle: textStyle(
color: Colors.grey, fontsize: font_14),
prefixIcon: icon != null
? Container(
padding: EdgeInsets.all(15.0),
height: 15.0,
width: 15.0,
child: Image(
image: AssetImage(icon),
height: 5.0,
width: 5.0,
))
: null,
suffixIcon: suffixIcon != null
? Container(
padding: EdgeInsets.all(15.0),
height: 15.0,
width: 15.0,
child: Image(
image: AssetImage(suffixIcon),
height: 5.0,
width: 5.0,
))
: null,
contentPadding: EdgeInsets.all(15),
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey.withOpacity(0.5), width: 0),
borderRadius: BorderRadius.circular(height_30)),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey.withOpacity(0.5), width: 0),
borderRadius: BorderRadius.circular(height_30)),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey.withOpacity(0.5), width: 0),
borderRadius: BorderRadius.circular(height_30)),
),
items: items,
onChanged: onChanged,
value: value,
),
),
);
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team