custom_static_dynamic_dropdown 0.0.2 copy "custom_static_dynamic_dropdown: ^0.0.2" to clipboard
custom_static_dynamic_dropdown: ^0.0.2 copied to clipboard

Custom Dropdown

example/lib/main.dart

import 'package:custom_static_dynamic_dropdown/custom_dropdown.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class AuthHelperConfig extends IAuthHelper {
  @override
  Future<String> getToken() async {
    return "Token assign";
  }
}

class DropDownConfig extends DropDownApiConfig {
  @override
  String getIdKey() {
    return "caseId";
  }

  @override
  String getSearchKeyNameInUrl() {
    return "searchStr";
  }

  @override
  String getUrl() {
    return "https://demo.url";
  }

  @override
  String getValueKey() {
    return "fullName";
  }

  @override
  int singlePageSize() {
    return 10;
  }
}

class _MyHomePageState extends State<MyHomePage> {
  List<CustomDropDownModel> listOfValues = [
    CustomDropDownModel(id: "0", valueDisplay: "0"),
    CustomDropDownModel(id: "1", valueDisplay: "1"),
    CustomDropDownModel(
        id: "2", valueDisplay: "2 custom long text which we can test on wrap"),
    CustomDropDownModel(id: "3", valueDisplay: "3"),
    CustomDropDownModel(id: "4", valueDisplay: "4"),
    CustomDropDownModel(id: "5", valueDisplay: "5"),
    CustomDropDownModel(id: "6", valueDisplay: "6"),
    CustomDropDownModel(id: "7", valueDisplay: "7"),
    CustomDropDownModel(id: "8", valueDisplay: "8"),
    CustomDropDownModel(id: "9", valueDisplay: "9"),
    CustomDropDownModel(id: "10", valueDisplay: "10"),
    CustomDropDownModel(id: "11", valueDisplay: "11"),
    CustomDropDownModel(id: "12", valueDisplay: "12"),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: [
              CommonConfigurationDropDown(
                  editorPlaceholder: "Static Data Single Select Dropdown",
                  child: StaticDataSingleSelectDropDown(
                      listOfValues: listOfValues)),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Static Data Single Select Searchable Dropdown",
                  child: StaticDataSingleSelectSearchableDropDown(
                      listOfValues: listOfValues)),
              CommonConfigurationDropDown(
                  editorPlaceholder: "Static data Multi Select Dropdown",
                  child: StaticDataMultiSelectDropDown(
                      listOfValues: listOfValues)),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Static Data Multi Select Searchable DropDown",
                  child: StaticDataMultiSelectSearchableDropDown(
                      listOfValues: listOfValues)),
              CommonConfigurationDropDown(
                  editorPlaceholder: "Dynamic Data Single Select Dropdown",
                  child: DynamicDataSingleSelectDropdown(
                      authHelper: AuthHelperConfig(),
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Single Select Searchable Dropdown",
                  child: DynamicDataSingleSelectSearchableDropdown(
                      authHelper: AuthHelperConfig(),
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Single Select Pagination Dropdown",
                  child: DynamicDataSingleSelectPaginationDropdown(
                      authHelper: AuthHelperConfig(),
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Single Select Searchable Pagination Dropdown",
                  child: DynamicDataSingleSelectSearchablePaginationDropdown(
                      authHelper: AuthHelperConfig(),
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder: "Dynamic Data Multi Select Dropdown",
                  child: DynamicDataMultiSelectDropdown(
                      authHelper: AuthHelperConfig(),
                      callbackSelectedValue: (p0) {
                        debugPrint("Selected is here ${p0}");
                      },
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Multi Select Pagination Dropdown",
                  child: DynamicDataMultiSelectPaginationDropdown(
                      authHelper: AuthHelperConfig(),
                      callbackSelectedValue: (p0) {
                        debugPrint("Selected is here ${p0}");
                      },
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Multi Select Searchable Pagination Dropdown",
                  child: DynamicDataMultiSelectSearchablePaginationDropdown(
                      authHelper: AuthHelperConfig(),
                      callbackSelectedValue: (p0) {
                        debugPrint("Selected is here ${p0}");
                      },
                      dropDownApiConfig: DropDownConfig())),
              CommonConfigurationDropDown(
                  editorPlaceholder:
                      "Dynamic Data Multi Select Searchable Dropdown",
                  child: DynamicDataMultiSelectSearchableDropdown(
                      authHelper: AuthHelperConfig(),
                      callbackSelectedValue: (p0) {
                        debugPrint("Selected is here ${p0}");
                      },
                      dropDownApiConfig: DropDownConfig())),
            ],
          ),
        ),
      ),
    );
  }
}