Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DropdownButtonFormField2 doesn't hide its underline. #241

Open
rirjkl19 opened this issue Feb 18, 2024 · 1 comment
Open

DropdownButtonFormField2 doesn't hide its underline. #241

rirjkl19 opened this issue Feb 18, 2024 · 1 comment

Comments

@rirjkl19
Copy link

Consider the code below:

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

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

  @override
  Widget build(BuildContext context) {
    return DropdownButtonHideUnderline(
      child: DropdownButtonFormField2(
        hint: const Text('Items'),
        value: null,
        items: const [
          DropdownMenuItem(
            value: 'item1',
            child: Text('item1'),
          ),
          DropdownMenuItem(
            value: 'item2',
            child: Text('item2'),
          ),
          DropdownMenuItem(
            value: 'item2',
            child: Text('item2'),
          ),
          
        ],
        onChanged: (val) {},
      ),
    );
  }
}

Was expecting that the Underline inside the DropdownButtonFormField2 would be hidden just like in the DropdownButtonField2.

I also noticed that DropdownButton2 has an option to have underline widget which I could just put SizedBox() inside which solves the problem without having a parent of DropdownButtonHideUnderline eliminating unnecessary widget nesting.

Can someone help me on this?

@jaydip-pawar
Copy link

As you are using DropdownButtonFormField2 you can simply hide the underline by adding InputDecoration,.

DropdownButtonFormField2<String>(
    decoration: InputDecoration(
        border: OutlineInputBorder(
            borderSide: BorderSide.none,
        ),
    ),
)

just add above code in your DropdownButtonFormField2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants