1

I'm working on a Spotify UI clon (the web version) on Flutter Web, and had implemented the top bar with the back/forward buttons and the user thing on the right, as a Column, but them realized that the bar is fixed on it's position, and that your music suggestions scroll through it.

My solution was to set a Stack with the bar on top, like so:

_mainScreen(BuildContext context){

    Size size = MediaQuery.of(context).size;

    return Container(
      padding: EdgeInsets.symmetric(horizontal: 15.0),
      color: Color.fromRGBO(22, 22, 22, 1.0),
      height: double.infinity,
      width: size.width*0.82,
      child: Stack(
        children: <Widget>[
          SingleChildScrollView(
            child: Column(
              children: <Widget>[
                SizedBox(height: size.height*0.09,),
                _suggestionLists(size)
              ],
            ),
          ),
          _topBar(size)
        ],
      )
    );
  }

And then this happened: That white line isn't supposed to be there

Neither it was there before making the changes I mentioned before. This is the code for that Widget:

_profileButtons(Size size){

    return Container(
      height: size.height*0.05,
      padding: EdgeInsets.symmetric(horizontal: 5.0),
      decoration: BoxDecoration(
        color: Color.fromRGBO(15, 15, 15, 0.8),
        borderRadius: BorderRadius.circular(100.0)
      ),
      child: DropdownButton<String>(
        dropdownColor: Color.fromRGBO(75, 75, 75, 1.0),
        style: TextStyle(color: Colors.white),
        hint: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              padding: EdgeInsets.all(1.0),
              child: Icon(Icons.person, color: Colors.white, size: 20,), 
              decoration: BoxDecoration(
                color: Color.fromRGBO(75, 75, 75, 1.0),
                border: Border.all(color: Color.fromRGBO(75, 75, 75, 1.0)),
                borderRadius: BorderRadius.circular(100.0)
                ),
            ),
            SizedBox(width: 5.0,),
            Text('Your UserName', style: TextStyle(color: Colors.white),),
          ],
        ),
        icon: Icon(Icons.arrow_drop_down, color: Colors.white,),
        items: <String>['Account', 'Profile', 'Log out'].map((String value) {
          return new DropdownMenuItem<String>(
            value: value,
            child: new Text(value),
          );
        }).toList(),
        onChanged: (_) {},
      )
    );
  }

I've tried messing up a bit with the container, borders, etc, but I don't seem to find what's wrong with it, could it be a render error? I'll provide extra code/details if required

2
  • I don't see any connection between these two pieces of code, can you give me more code? Commented Dec 11, 2020 at 1:43
  • Oh I messed up, it's missing the code that links them, anyway someone answered something promising, I'll try that tomorrow Commented Dec 11, 2020 at 5:01

1 Answer 1

1

You can copy paste run full code below
To hide underline, you can use DropdownButtonHideUnderline wrap DropdownButton
code snippet

DropdownButtonHideUnderline(
          child: DropdownButton<String>(

working demo

enter image description here

full code

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  _profileButtons(Size size) {
    return Container(
        height: size.height * 0.05,
        padding: EdgeInsets.symmetric(horizontal: 5.0),
        decoration: BoxDecoration(
            color: Color.fromRGBO(15, 15, 15, 0.8),
            borderRadius: BorderRadius.circular(100.0)),
        child: DropdownButtonHideUnderline(
          child: DropdownButton<String>(
            dropdownColor: Color.fromRGBO(75, 75, 75, 1.0),
            style: TextStyle(color: Colors.white),
            hint: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Container(
                  padding: EdgeInsets.all(1.0),
                  child: Icon(
                    Icons.person,
                    color: Colors.white,
                    size: 20,
                  ),
                  decoration: BoxDecoration(
                      color: Color.fromRGBO(75, 75, 75, 1.0),
                      border:
                          Border.all(color: Color.fromRGBO(75, 75, 75, 1.0)),
                      borderRadius: BorderRadius.circular(100.0)),
                ),
                SizedBox(
                  width: 5.0,
                ),
                Text(
                  'Your UserName',
                  style: TextStyle(color: Colors.white),
                ),
              ],
            ),
            icon: Icon(
              Icons.arrow_drop_down,
              color: Colors.white,
            ),
            items:
                <String>['Account', 'Profile', 'Log out'].map((String value) {
              return new DropdownMenuItem<String>(
                value: value,
                child: new Text(value),
              );
            }).toList(),
            onChanged: (_) {},
          ),
        ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(appBar: AppBar(), body: _profileButtons(Size(800, 800)));
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Tried it, worked like a charm, thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.