--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/e7047ec1-d2df-4b84-97ec-e7556f93200f%40googlegroups.com.
import 'package:dropdowonsample/contacts.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider.value(
value: ContactService(),
),
],
child: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<Contacts> finalList = [];
final _controllerStartDate = TextEditingController();
@override
void dispose() {
finalList.clear();
}
Widget _createDropDownButton(List<Contacts> _cont, BuildContext context) {
return Consumer<ContactService>(builder: (ctx, d, ch) {
return DropdownButton(
key: GlobalKey(),
value: d.getSelectedValue(), // _selectedValue,
items: _cont
.map(
(e) => DropdownMenuItem(
value: e.id,
child: Text(e.name),
onTap: () {},
),
)
.toList(),
onChanged: (value) {
Provider.of<ContactService>(context, listen: false)
.setIsSelected(value);
},
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Consumer<ContactService>(
builder: (ctx, d, ch) {
return Text(
d.getSelectedValue() == null ? "hello" : d.getSelectedValue(),
style: Theme.of(context).textTheme.headline4,
);
},
),
FutureBuilder(
future: Provider.of<ContactService>(context, listen: false)
.getPlans(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return _createDropDownButton(snapshot.data,
context); // Text(snapshot.data.length.toString());
} else {
return Text("Waiting");
}
},
),
TextFormField(
key: GlobalKey(),
controller: _controllerStartDate,
decoration: InputDecoration(
labelText: "Enter Start Date :",
),
onTap: () async {
DateTime date = DateTime(1900);
FocusScope.of(context).requestFocus(new FocusNode());
date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1900),
lastDate: DateTime(2100));
_controllerStartDate.text = date.toIso8601String();
},
),
],
),
),
);
}
}
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/a2da224b-ea33-4c5b-ac98-08e6c2632508%40googlegroups.com.
Here is the Code--------------------------------------
Tejas Kishanwala
On Thursday, 21 May 2020 16:17:01 UTC+5:30, Souvik Dutta wrote:
Can you copy and paste the code from main.dart instead of attaching it?
On Thu, 21 May, 2020, 3:04 pm Dareboy Dareboy, <dareb...@gmail.com> wrote:
--i have attached fileafter selecting dropdown value, and then select date from datepicker, then when i once again select dropdown button, it will not work.Is something i missed ?
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/e7047ec1-d2df-4b84-97ec-e7556f93200f%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/d7e4584e-6ece-4f88-8bf8-fda715d7599a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/d7e4584e-6ece-4f88-8bf8-fda715d7599a%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/c5e23d85-f09c-4a0c-a22b-0b5d405f0ed7%40googlegroups.com.