How to remove Padding from DrawerHeader
up vote
0
down vote
favorite
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:
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
:
It works as it should!
Am I missing something, or is this a bug in Flutter?
flutter flutter-layout
add a comment |
up vote
0
down vote
favorite
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:
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
:
It works as it should!
Am I missing something, or is this a bug in Flutter?
flutter flutter-layout
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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:
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
:
It works as it should!
Am I missing something, or is this a bug in Flutter?
flutter flutter-layout
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:
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
:
It works as it should!
Am I missing something, or is this a bug in Flutter?
flutter flutter-layout
flutter flutter-layout
asked Nov 18 at 16:25
mFeinstein
2,09972774
2,09972774
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
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),
),
],
),
),
),
add a comment |
up vote
0
down vote
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
Oh yeah, you are right!_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!
– mFeinstein
Nov 19 at 23:25
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
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),
),
],
),
),
),
add a comment |
up vote
0
down vote
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),
),
],
),
),
),
add a comment |
up vote
0
down vote
up vote
0
down vote
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),
),
],
),
),
),
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),
),
],
),
),
),
edited Nov 18 at 17:18
answered Nov 18 at 17:13
Saed Nabil
2046
2046
add a comment |
add a comment |
up vote
0
down vote
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
Oh yeah, you are right!_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!
– mFeinstein
Nov 19 at 23:25
add a comment |
up vote
0
down vote
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
Oh yeah, you are right!_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!
– mFeinstein
Nov 19 at 23:25
add a comment |
up vote
0
down vote
up vote
0
down vote
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
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
answered Nov 19 at 7:31
Andrey Turkovsky
1,4671615
1,4671615
Oh yeah, you are right!_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!
– mFeinstein
Nov 19 at 23:25
add a comment |
Oh yeah, you are right!_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!
– mFeinstein
Nov 19 at 23:25
Oh yeah, you are right!
_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!– mFeinstein
Nov 19 at 23:25
Oh yeah, you are right!
_kDrawerHeaderHeight
is defined on the top of the class, I missed it! Thanks!– mFeinstein
Nov 19 at 23:25
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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