async_searchable_dropdown 0.0.4+2 copy "async_searchable_dropdown: ^0.0.4+2" to clipboard
async_searchable_dropdown: ^0.0.4+2 copied to clipboard

outdated

Flutter async searchable dropdown widget.

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:async_searchable_dropdown/async_searchable_dropdown.dart';

final data = [
  "hello",
  "xyzw",
  "bilal",
  "Romio",
  "Cats in the rain",
  "Ali",
];

Future<List<String>> getData(String? search) async {
  await Future.delayed(const Duration(seconds: 2));
  if (Random().nextBool()) throw 'sdd';
  return data.where((e) => e.contains(search ?? '')).toList();
}

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  final ValueNotifier<String?> selectedValue = ValueNotifier<String?>(null);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Async Searchable Dropdown Example'),
        ),
        body: Column(
          children: [
            const SizedBox(height: 20),
            ValueListenableBuilder<String?>(
              valueListenable: selectedValue,
              builder: (context, value, child) {
                return SearchableDropdown<String>(
                  backgroundDecoration: (child) => Card(
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(15.0)),
                    child: child,
                  ),
                  value: value,
                  itemLabelFormatter: (value) {
                    return value;
                  },
                  labelText: 'List of items',
                  margin: const EdgeInsets.all(15),
                  remoteItems: getData,
                  onChanged: (value) {
                    selectedValue.value = value;
                    debugPrint('$value');
                  },
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
11
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter async searchable dropdown widget.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

async, flutter

More

Packages that depend on async_searchable_dropdown