How to remove Padding from DrawerHeader












0















Here's my DrawerHeader :



class MyDrawerHeader extends StatefulWidget {
@override
_MyDrawerHeaderState createState() => _MyDrawerHeaderState();
}

class _MyDrawerHeaderState extends State<MyDrawerHeader> {
@override
Widget build(BuildContext context) {
return DrawerHeader(
padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0),
child: Center(child: Text('Header', style: Theme.of(context).textTheme.headline))
);
}
}


As you can see I made the Padding and Margin from the DrawerHeader be 0, but this is how my Header is being shown:



Big Drawer Header



It's just too big and I can't make it smaller. I have no idea why its being rendered this way, I looked into DrawerHeader source code and I can't see anything in there overriding my Padding or Margin.



Just to be sure the problem is in DrawerHeader, this is what Happens when I substitute it for a Container:



Small Header



It works as it should!



Am I missing something, or is this a bug in Flutter?










share|improve this question



























    0















    Here's my DrawerHeader :



    class MyDrawerHeader extends StatefulWidget {
    @override
    _MyDrawerHeaderState createState() => _MyDrawerHeaderState();
    }

    class _MyDrawerHeaderState extends State<MyDrawerHeader> {
    @override
    Widget build(BuildContext context) {
    return DrawerHeader(
    padding: EdgeInsets.all(0),
    margin: EdgeInsets.all(0),
    child: Center(child: Text('Header', style: Theme.of(context).textTheme.headline))
    );
    }
    }


    As you can see I made the Padding and Margin from the DrawerHeader be 0, but this is how my Header is being shown:



    Big Drawer Header



    It's just too big and I can't make it smaller. I have no idea why its being rendered this way, I looked into DrawerHeader source code and I can't see anything in there overriding my Padding or Margin.



    Just to be sure the problem is in DrawerHeader, this is what Happens when I substitute it for a Container:



    Small Header



    It works as it should!



    Am I missing something, or is this a bug in Flutter?










    share|improve this question

























      0












      0








      0


      1






      Here's my DrawerHeader :



      class MyDrawerHeader extends StatefulWidget {
      @override
      _MyDrawerHeaderState createState() => _MyDrawerHeaderState();
      }

      class _MyDrawerHeaderState extends State<MyDrawerHeader> {
      @override
      Widget build(BuildContext context) {
      return DrawerHeader(
      padding: EdgeInsets.all(0),
      margin: EdgeInsets.all(0),
      child: Center(child: Text('Header', style: Theme.of(context).textTheme.headline))
      );
      }
      }


      As you can see I made the Padding and Margin from the DrawerHeader be 0, but this is how my Header is being shown:



      Big Drawer Header



      It's just too big and I can't make it smaller. I have no idea why its being rendered this way, I looked into DrawerHeader source code and I can't see anything in there overriding my Padding or Margin.



      Just to be sure the problem is in DrawerHeader, this is what Happens when I substitute it for a Container:



      Small Header



      It works as it should!



      Am I missing something, or is this a bug in Flutter?










      share|improve this question














      Here's my DrawerHeader :



      class MyDrawerHeader extends StatefulWidget {
      @override
      _MyDrawerHeaderState createState() => _MyDrawerHeaderState();
      }

      class _MyDrawerHeaderState extends State<MyDrawerHeader> {
      @override
      Widget build(BuildContext context) {
      return DrawerHeader(
      padding: EdgeInsets.all(0),
      margin: EdgeInsets.all(0),
      child: Center(child: Text('Header', style: Theme.of(context).textTheme.headline))
      );
      }
      }


      As you can see I made the Padding and Margin from the DrawerHeader be 0, but this is how my Header is being shown:



      Big Drawer Header



      It's just too big and I can't make it smaller. I have no idea why its being rendered this way, I looked into DrawerHeader source code and I can't see anything in there overriding my Padding or Margin.



      Just to be sure the problem is in DrawerHeader, this is what Happens when I substitute it for a Container:



      Small Header



      It works as it should!



      Am I missing something, or is this a bug in Flutter?







      flutter flutter-layout






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 '18 at 16:25









      mFeinsteinmFeinstein

      2,24372777




      2,24372777
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Try replacing your drawer by the code below



          drawer: Drawer(
          child: DrawerHeader(
          child: ListView(
          children: <Widget>[
          Container(
          alignment: Alignment.topLeft,
          child: Text('Header', style: Theme.of(context).textTheme.headline),
          ),
          ],
          ),
          ),
          ),





          share|improve this answer

































            0














            There is always padding on DrawerHeader. If you look in sources:



            @override
            Widget build(BuildContext context) {
            assert(debugCheckHasMaterial(context));
            assert(debugCheckHasMediaQuery(context));
            final ThemeData theme = Theme.of(context);
            final double statusBarHeight = MediaQuery.of(context).padding.top;
            return Container(
            height: statusBarHeight + _kDrawerHeaderHeight,
            margin: margin,
            decoration: BoxDecoration(
            border: Border(
            bottom: Divider.createBorderSide(context),
            ),
            ),
            child: AnimatedContainer(
            padding: padding.add(EdgeInsets.only(top: statusBarHeight)),
            decoration: decoration,
            duration: duration,
            curve: curve,
            child: child == null ? null : DefaultTextStyle(
            style: theme.textTheme.body2,
            child: MediaQuery.removePadding(
            context: context,
            removeTop: true,
            child: child,
            ),
            ),
            ),
            );
            }


            You can customize this code:



            height: statusBarHeight + _kDrawerHeaderHeight - here is total height of header



            padding: padding.add(EdgeInsets.only(top: statusBarHeight)) - here is padding of child element in DrawerHeader






            share|improve this answer
























            • Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

              – mFeinstein
              Nov 19 '18 at 23:25











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53363029%2fhow-to-remove-padding-from-drawerheader%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Try replacing your drawer by the code below



            drawer: Drawer(
            child: DrawerHeader(
            child: ListView(
            children: <Widget>[
            Container(
            alignment: Alignment.topLeft,
            child: Text('Header', style: Theme.of(context).textTheme.headline),
            ),
            ],
            ),
            ),
            ),





            share|improve this answer






























              0














              Try replacing your drawer by the code below



              drawer: Drawer(
              child: DrawerHeader(
              child: ListView(
              children: <Widget>[
              Container(
              alignment: Alignment.topLeft,
              child: Text('Header', style: Theme.of(context).textTheme.headline),
              ),
              ],
              ),
              ),
              ),





              share|improve this answer




























                0












                0








                0







                Try replacing your drawer by the code below



                drawer: Drawer(
                child: DrawerHeader(
                child: ListView(
                children: <Widget>[
                Container(
                alignment: Alignment.topLeft,
                child: Text('Header', style: Theme.of(context).textTheme.headline),
                ),
                ],
                ),
                ),
                ),





                share|improve this answer















                Try replacing your drawer by the code below



                drawer: Drawer(
                child: DrawerHeader(
                child: ListView(
                children: <Widget>[
                Container(
                alignment: Alignment.topLeft,
                child: Text('Header', style: Theme.of(context).textTheme.headline),
                ),
                ],
                ),
                ),
                ),






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 18 '18 at 17:18

























                answered Nov 18 '18 at 17:13









                Saed NabilSaed Nabil

                1,19828




                1,19828

























                    0














                    There is always padding on DrawerHeader. If you look in sources:



                    @override
                    Widget build(BuildContext context) {
                    assert(debugCheckHasMaterial(context));
                    assert(debugCheckHasMediaQuery(context));
                    final ThemeData theme = Theme.of(context);
                    final double statusBarHeight = MediaQuery.of(context).padding.top;
                    return Container(
                    height: statusBarHeight + _kDrawerHeaderHeight,
                    margin: margin,
                    decoration: BoxDecoration(
                    border: Border(
                    bottom: Divider.createBorderSide(context),
                    ),
                    ),
                    child: AnimatedContainer(
                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)),
                    decoration: decoration,
                    duration: duration,
                    curve: curve,
                    child: child == null ? null : DefaultTextStyle(
                    style: theme.textTheme.body2,
                    child: MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: child,
                    ),
                    ),
                    ),
                    );
                    }


                    You can customize this code:



                    height: statusBarHeight + _kDrawerHeaderHeight - here is total height of header



                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)) - here is padding of child element in DrawerHeader






                    share|improve this answer
























                    • Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                      – mFeinstein
                      Nov 19 '18 at 23:25
















                    0














                    There is always padding on DrawerHeader. If you look in sources:



                    @override
                    Widget build(BuildContext context) {
                    assert(debugCheckHasMaterial(context));
                    assert(debugCheckHasMediaQuery(context));
                    final ThemeData theme = Theme.of(context);
                    final double statusBarHeight = MediaQuery.of(context).padding.top;
                    return Container(
                    height: statusBarHeight + _kDrawerHeaderHeight,
                    margin: margin,
                    decoration: BoxDecoration(
                    border: Border(
                    bottom: Divider.createBorderSide(context),
                    ),
                    ),
                    child: AnimatedContainer(
                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)),
                    decoration: decoration,
                    duration: duration,
                    curve: curve,
                    child: child == null ? null : DefaultTextStyle(
                    style: theme.textTheme.body2,
                    child: MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: child,
                    ),
                    ),
                    ),
                    );
                    }


                    You can customize this code:



                    height: statusBarHeight + _kDrawerHeaderHeight - here is total height of header



                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)) - here is padding of child element in DrawerHeader






                    share|improve this answer
























                    • Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                      – mFeinstein
                      Nov 19 '18 at 23:25














                    0












                    0








                    0







                    There is always padding on DrawerHeader. If you look in sources:



                    @override
                    Widget build(BuildContext context) {
                    assert(debugCheckHasMaterial(context));
                    assert(debugCheckHasMediaQuery(context));
                    final ThemeData theme = Theme.of(context);
                    final double statusBarHeight = MediaQuery.of(context).padding.top;
                    return Container(
                    height: statusBarHeight + _kDrawerHeaderHeight,
                    margin: margin,
                    decoration: BoxDecoration(
                    border: Border(
                    bottom: Divider.createBorderSide(context),
                    ),
                    ),
                    child: AnimatedContainer(
                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)),
                    decoration: decoration,
                    duration: duration,
                    curve: curve,
                    child: child == null ? null : DefaultTextStyle(
                    style: theme.textTheme.body2,
                    child: MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: child,
                    ),
                    ),
                    ),
                    );
                    }


                    You can customize this code:



                    height: statusBarHeight + _kDrawerHeaderHeight - here is total height of header



                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)) - here is padding of child element in DrawerHeader






                    share|improve this answer













                    There is always padding on DrawerHeader. If you look in sources:



                    @override
                    Widget build(BuildContext context) {
                    assert(debugCheckHasMaterial(context));
                    assert(debugCheckHasMediaQuery(context));
                    final ThemeData theme = Theme.of(context);
                    final double statusBarHeight = MediaQuery.of(context).padding.top;
                    return Container(
                    height: statusBarHeight + _kDrawerHeaderHeight,
                    margin: margin,
                    decoration: BoxDecoration(
                    border: Border(
                    bottom: Divider.createBorderSide(context),
                    ),
                    ),
                    child: AnimatedContainer(
                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)),
                    decoration: decoration,
                    duration: duration,
                    curve: curve,
                    child: child == null ? null : DefaultTextStyle(
                    style: theme.textTheme.body2,
                    child: MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: child,
                    ),
                    ),
                    ),
                    );
                    }


                    You can customize this code:



                    height: statusBarHeight + _kDrawerHeaderHeight - here is total height of header



                    padding: padding.add(EdgeInsets.only(top: statusBarHeight)) - here is padding of child element in DrawerHeader







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 19 '18 at 7:31









                    Andrey TurkovskyAndrey Turkovsky

                    2,4472828




                    2,4472828













                    • Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                      – mFeinstein
                      Nov 19 '18 at 23:25



















                    • Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                      – mFeinstein
                      Nov 19 '18 at 23:25

















                    Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                    – mFeinstein
                    Nov 19 '18 at 23:25





                    Oh yeah, you are right! _kDrawerHeaderHeight is defined on the top of the class, I missed it! Thanks!

                    – mFeinstein
                    Nov 19 '18 at 23:25


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53363029%2fhow-to-remove-padding-from-drawerheader%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to pass form data using jquery Ajax to insert data in database?

                    National Museum of Racing and Hall of Fame

                    Guess what letter conforming each word