You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:multiselect_dropdown_flutter/multiselect_dropdown_flutter.dart';
void main() {
runApp(const MyApp());
}
class Controller extends GetxController {
var names = <Map<String, dynamic>>[].obs;
@override
void onInit() {
super.onInit();
fetchDataFromNetwork();
}
Future<void> fetchDataFromNetwork() async {
// Эмулируем задержку, как будто данные загружаются из сети
await Future.delayed(Duration(seconds: 1));
// Получаем данные (в данном случае, данные получаются с сервера)
final List<Map<String, dynamic>> data = [
{'id': 'dog', 'label': 'Dog'},
{'id': 'cat', 'label': 'Cat'},
{'id': 'mouse', 'label': 'Mouse'},
{'id': 'rabbit', 'label': 'Rabbit'},
];
names.assignAll(data);
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'MultiSelect Dropdown demo',
home: MultiSelectExample(),
);
}
}
class MultiSelectExample extends StatelessWidget {
const MultiSelectExample({super.key});
@override
Widget build(BuildContext context) {
final Controller ctrl = Get.put(Controller());
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
MultiSelectDropdown(
list: ctrl.names,
initiallySelected: const [],
onChange: (newList) {
// your logic
// typically setting state
},
numberOfItemsLabelToShow: 2, // label to be shown for 2 items
whenEmpty:
'Choose from the list', // text to show when selected list is empty
),
],
),
),
);
}
}
pubspec.yaml:
dependencies:
flutter:
sdk: flutter
multiselect_dropdown_flutter: ^0.0.7
get: ^5.0.0-release-candidate-4
```
result: can't select anything from dropdown like it have no any data.
The text was updated successfully, but these errors were encountered:
Populating data from network, and dropdown shows no values or what so ever. Checked for state refresh as well. State refresh call is given and it's not showing any data.
pubspec.yaml:
The text was updated successfully, but these errors were encountered: