AlertDialog Dropdown kontrol

2.29K görüntülenmeFlutter Genelalertdialog dropdown statefulbuilder

AlertDialog Dropdown kontrol

Merhaba,

Ekrandaki FİLTRELE butonuna basıldığında açılan ALERTDIALOG içerisinde DROPDOWN kullanarak seçim yaptırıyorum. Fakat StateFulWidget kullanmama rağmen yaptığım değişiklik ekranda gözükmüyor. Ancak Fİltrele butonuna bastığımda alertdialog kapanıyor ve ana ekranımdaki değişiklik gerçekleşiyor. DROPDOWN daki değişikliği göstermek için SHOWDIALOG içerisinde STATEFULBUILDER kullanıyorum. Bu durumda dropdown daki her değişiklik ekranda gözüküyor. Bu sefer de  Dropdown altında bulunan FİLTRELE butonu çalışmıyor.

import ‘dart:ui’;
import ‘package:flutter/Material.dart’;
import ‘ariza/ariza_services.dart’ as servisler;
import ‘ariza/ariza_model.dart’;

class birimeAtanan extends StatefulWidget {
@override
_birimeAtananState createState() => _birimeAtananState();
}
class _birimeAtananState extends State<birimeAtanan> {
// ignore: deprecated_member_use
List<Ariza> _notes = List<Ariza>();
String dropdownValue;
String dropdownValueDurum;
// ignore: deprecated_member_use
List<Ariza> project = List<Ariza>();
@override
void initState() {
servisler.fetchNotes().then((value) {
setState(() {
_notes.addAll(value);
project = _notes;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return ListView.builder(
itemBuilder: (context, index) {
return index == 0 ? _searchBar() : _listItem(index – 1);
},
itemCount: project.length + 1,
);
}
_searchBar() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton.icon(

onPressed: () {
//  setState(() {
showDialog<String>(
context: context,
builder: (BuildContext context) {

return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
contentPadding: const EdgeInsets.all(16.0),
content: new Row(
children: <Widget>[
new Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButton<String>(
isExpanded: true,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 160,
style: TextStyle(color: Colors.deepPurple),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
this.dropdownValueDurum = dropdownValue;
print(“dropdownvalueDurum : ” +
dropdownValueDurum);
print(“dropdownValue : ” + dropdownValue);

});
},
hint: Text(“seçiniz…”),
items: <String>[
”,
‘Beklemede’,
‘İşleme Alındı’,
‘İleri Tarihe Planlandı’,
‘Kullanıcı Onayında’
].map<DropdownMenuItem<String>>(
(String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
value: dropdownValueDurum,
),

],
),
)
],
),
actions: <Widget>[
new FlatButton(
child: const Text(‘Çıkış’),
onPressed: () {
Navigator.pop(context);
}),
new FlatButton(
child: const Text(‘Filtrele’),
onPressed: () {
//setState(() {
project = _notes.where((note) {
var noteTitle = note.durumu;
return noteTitle.contains(
dropdownValueDurum);
}).toList();
// });
Navigator.pop(context);
})
]);
});

});
},
style: ElevatedButton.styleFrom(
textStyle: TextStyle(color: Colors.lightBlue),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
),
label: Text(
‘Filtrele’,
),
icon: Icon(
Icons.search,
color: Colors.white,
),
),
);
}
_listItem(index) {
return Card(
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Padding(
padding: new EdgeInsets.all(16.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
new Text(
project[index].id.toString(),
style: TextStyle(color: Colors.blue),
),
new Text(
” / ” + project[index].bildirimTarihi.substring(0, 10),
style: TextStyle(color: Colors.blue),
),
],
),
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Text(project[index].durumu,
style: TextStyle(
fontSize: 14,
color: project[index].durumu == ‘Beklemede’
? Colors.redAccent
: Colors.green)),
],
),
],
),
),
],
),
//  ),
);
}
}

Bestami ARACI Durumu yayınlanmak üzere'ye değiştirildi 3 Mayıs 2021
1