Widget build()

in ui/lib/modules/catalog/widgets/git_owners_dropdown.dart [45:93]


  Widget build(BuildContext parentContext) {
    final asyncGitSettingsValue = ref.watch(gitSettingsProvider);

    return asyncGitSettingsValue.when(
      data: (gitSettings) {
        return SizedBox(
          width: 300,
          child: DropdownButtonFormField<String>(
            validator: (value) {
              if (value == null ||
                  value.isEmpty ||
                  value == "Select an owner") {
                return 'This field is required';
              }
              return null;
            },
            hint: Text("Select an owner"),
            value: dropdownValue,
            icon: const Icon(Icons.arrow_drop_down),
            style: const TextStyle(color: Colors.black),
            onChanged: (String? value) {
              setState(() {
                dropdownValue = value!;
                widget.onTextFormUpdate(
                    value, "_INSTANCE_GIT_REPO_OWNER");
              });
            },
            items: [
              "Select an owner",
              "https://github.com/${gitSettings.instanceGitUsername}"
            ].map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
          ),
        );
      },
      loading: () => const Center(
        child: CircularProgressIndicator(),
      ),
      error: (err, st) => Center(
        child: Text(
          err.toString(),
        ),
      ),
    );
  }