Flutter custom AppBar and bottomNavigationBar Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Flutter: Tabbar vs BottomNavigationBarHow to get constraints like Height and Width of container in flutterFlutter layout without AppBarFlutter : Can I add a Header Row to a ListViewHow to offset a scaffold widget in Flutter?Flutter : Bad state: Stream has already been listened toFlutter: AutomaticKeepAliveClientMixin is not working with BottomNavigationBarGetting the position of a widget in a Flutter test?Custom AppBar FlutterFlutter / flutter_webview_plugin => hide/show AppBar + BottomNavigationBar on Scroll down/up
Why weren't discrete x86 CPUs ever used in game hardware?
Sally's older brother
Is multiple magic items in one inherently imbalanced?
A term for a woman complaining about things/begging in a cute/childish way
How can god fight other gods?
Google .dev domain strangely redirects to https
Why datecode is SO IMPORTANT to chip manufacturers?
Can you force honesty by using the Speak with Dead and Zone of Truth spells together?
Is it dangerous to install hacking tools on my private linux machine?
Special flights
How to change the tick of the color bar legend to black
What is the "studentd" process?
How do living politicians protect their readily obtainable signatures from misuse?
Why is it faster to reheat something than it is to cook it?
Mounting TV on a weird wall that has some material between the drywall and stud
Printing attributes of selection in ArcPy?
Delete free apps from library
What are the main differences between the original Stargate SG-1 and the Final Cut edition?
Why is a lens darker than other ones when applying the same settings?
Does silver oxide react with hydrogen sulfide?
I got rid of Mac OSX and replaced it with linux but now I can't change it back to OSX or windows
Why is std::move not [[nodiscard]] in C++20?
One-one communication
White walkers, cemeteries and wights
Flutter custom AppBar and bottomNavigationBar
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Flutter: Tabbar vs BottomNavigationBarHow to get constraints like Height and Width of container in flutterFlutter layout without AppBarFlutter : Can I add a Header Row to a ListViewHow to offset a scaffold widget in Flutter?Flutter : Bad state: Stream has already been listened toFlutter: AutomaticKeepAliveClientMixin is not working with BottomNavigationBarGetting the position of a widget in a Flutter test?Custom AppBar FlutterFlutter / flutter_webview_plugin => hide/show AppBar + BottomNavigationBar on Scroll down/up
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Can someone help me achieve custom Header(AppBar) and footer(bottomNavigationBar). The Header height resize min:20 to max:50 and Footer pinned(show/hide) according to user scroll. In most case, the header should be very much like AppBar/SliverAppbar.
The reason custom Header/Footer is that I need to draw widget shape over AppBar and bottomNavigationBar. And with the default AppBar/bottomNavigationBar there is no way to customized the index, so whatever widget shape i have in the body is alway stay in the back.
This is the code I am working on, its seem a little bit acceptable, would you help me improve?
import 'package:flutter/material.dart';
class CustomScrollOne extends StatefulWidget
@override
CustomScrollOneState createState() => new CustomScrollOneState();
class CustomScrollOneState extends State<CustomScrollOne> with SingleTickerProviderStateMixin
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
ScrollController scrollController;
double scrollOffset = 0.0;
double scrollOffsetLast = 0.0;
double upperSize = 50.0;
@override
initState()
scrollController = new ScrollController();
scrollController.addListener(updateOffset);
super.initState();
@override
dispose()
scrollController.removeListener(updateOffset);
scrollController.dispose();
super.dispose();
void updateOffset()
setState(()
scrollOffset = scrollController.offset;
);
scrollNotificationListener(ScrollNotification scrollNotification)
if (scrollNotification is ScrollUpdateNotification)
double minTop = 20.0;
double maxTop = 50.0;
if (scrollNotification.scrollDelta < 0)
// NOTE forward to normal
if (upperSize < maxTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(upperSize, maxTop);
else if (scrollNotification.scrollDelta > 0)
// NOTE reverse to large
if (upperSize > minTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(minTop, upperSize);
else if (scrollNotification is ScrollEndNotification)
scrollOffsetLast = scrollController.offset;
@override
Widget build(BuildContext context)
return Scaffold(
key: scaffoldKey,
backgroundColor: Colors.white,
body: new SafeArea(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
top: upperSize,
left: 14,
right:14,
bottom: 50,
child: Container(
color: Colors.grey[200],
child: NotificationListener<ScrollNotification>(
onNotification: (e)=>scrollNotificationListener(e),
child: _listView(),
)
),
),
Positioned(
top: 0,
left: 50,
right: 50,
child: Container(
width: 300,
height: upperSize,
color: Colors.grey[100],
child: Text(upperSize.toString()),
),
),
Positioned(
top: 0,
left: 1,
bottom: 0,
child: Container(
width: 10,
height: upperSize,
color: Colors.red
)
)
]
)
)
);
Widget _listView()
return new ListView.builder(
itemCount: 60,
itemBuilder: _listViewItem,
controller: scrollController
);
Widget _listViewItem(BuildContext context, int index)
return new Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[50],
// border: Border.all(width:0.2,color: Colors.grey)
),
child: new Text('Item $index')
);
dart flutter
add a comment |
Can someone help me achieve custom Header(AppBar) and footer(bottomNavigationBar). The Header height resize min:20 to max:50 and Footer pinned(show/hide) according to user scroll. In most case, the header should be very much like AppBar/SliverAppbar.
The reason custom Header/Footer is that I need to draw widget shape over AppBar and bottomNavigationBar. And with the default AppBar/bottomNavigationBar there is no way to customized the index, so whatever widget shape i have in the body is alway stay in the back.
This is the code I am working on, its seem a little bit acceptable, would you help me improve?
import 'package:flutter/material.dart';
class CustomScrollOne extends StatefulWidget
@override
CustomScrollOneState createState() => new CustomScrollOneState();
class CustomScrollOneState extends State<CustomScrollOne> with SingleTickerProviderStateMixin
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
ScrollController scrollController;
double scrollOffset = 0.0;
double scrollOffsetLast = 0.0;
double upperSize = 50.0;
@override
initState()
scrollController = new ScrollController();
scrollController.addListener(updateOffset);
super.initState();
@override
dispose()
scrollController.removeListener(updateOffset);
scrollController.dispose();
super.dispose();
void updateOffset()
setState(()
scrollOffset = scrollController.offset;
);
scrollNotificationListener(ScrollNotification scrollNotification)
if (scrollNotification is ScrollUpdateNotification)
double minTop = 20.0;
double maxTop = 50.0;
if (scrollNotification.scrollDelta < 0)
// NOTE forward to normal
if (upperSize < maxTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(upperSize, maxTop);
else if (scrollNotification.scrollDelta > 0)
// NOTE reverse to large
if (upperSize > minTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(minTop, upperSize);
else if (scrollNotification is ScrollEndNotification)
scrollOffsetLast = scrollController.offset;
@override
Widget build(BuildContext context)
return Scaffold(
key: scaffoldKey,
backgroundColor: Colors.white,
body: new SafeArea(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
top: upperSize,
left: 14,
right:14,
bottom: 50,
child: Container(
color: Colors.grey[200],
child: NotificationListener<ScrollNotification>(
onNotification: (e)=>scrollNotificationListener(e),
child: _listView(),
)
),
),
Positioned(
top: 0,
left: 50,
right: 50,
child: Container(
width: 300,
height: upperSize,
color: Colors.grey[100],
child: Text(upperSize.toString()),
),
),
Positioned(
top: 0,
left: 1,
bottom: 0,
child: Container(
width: 10,
height: upperSize,
color: Colors.red
)
)
]
)
)
);
Widget _listView()
return new ListView.builder(
itemCount: 60,
itemBuilder: _listViewItem,
controller: scrollController
);
Widget _listViewItem(BuildContext context, int index)
return new Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[50],
// border: Border.all(width:0.2,color: Colors.grey)
),
child: new Text('Item $index')
);
dart flutter
add a comment |
Can someone help me achieve custom Header(AppBar) and footer(bottomNavigationBar). The Header height resize min:20 to max:50 and Footer pinned(show/hide) according to user scroll. In most case, the header should be very much like AppBar/SliverAppbar.
The reason custom Header/Footer is that I need to draw widget shape over AppBar and bottomNavigationBar. And with the default AppBar/bottomNavigationBar there is no way to customized the index, so whatever widget shape i have in the body is alway stay in the back.
This is the code I am working on, its seem a little bit acceptable, would you help me improve?
import 'package:flutter/material.dart';
class CustomScrollOne extends StatefulWidget
@override
CustomScrollOneState createState() => new CustomScrollOneState();
class CustomScrollOneState extends State<CustomScrollOne> with SingleTickerProviderStateMixin
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
ScrollController scrollController;
double scrollOffset = 0.0;
double scrollOffsetLast = 0.0;
double upperSize = 50.0;
@override
initState()
scrollController = new ScrollController();
scrollController.addListener(updateOffset);
super.initState();
@override
dispose()
scrollController.removeListener(updateOffset);
scrollController.dispose();
super.dispose();
void updateOffset()
setState(()
scrollOffset = scrollController.offset;
);
scrollNotificationListener(ScrollNotification scrollNotification)
if (scrollNotification is ScrollUpdateNotification)
double minTop = 20.0;
double maxTop = 50.0;
if (scrollNotification.scrollDelta < 0)
// NOTE forward to normal
if (upperSize < maxTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(upperSize, maxTop);
else if (scrollNotification.scrollDelta > 0)
// NOTE reverse to large
if (upperSize > minTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(minTop, upperSize);
else if (scrollNotification is ScrollEndNotification)
scrollOffsetLast = scrollController.offset;
@override
Widget build(BuildContext context)
return Scaffold(
key: scaffoldKey,
backgroundColor: Colors.white,
body: new SafeArea(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
top: upperSize,
left: 14,
right:14,
bottom: 50,
child: Container(
color: Colors.grey[200],
child: NotificationListener<ScrollNotification>(
onNotification: (e)=>scrollNotificationListener(e),
child: _listView(),
)
),
),
Positioned(
top: 0,
left: 50,
right: 50,
child: Container(
width: 300,
height: upperSize,
color: Colors.grey[100],
child: Text(upperSize.toString()),
),
),
Positioned(
top: 0,
left: 1,
bottom: 0,
child: Container(
width: 10,
height: upperSize,
color: Colors.red
)
)
]
)
)
);
Widget _listView()
return new ListView.builder(
itemCount: 60,
itemBuilder: _listViewItem,
controller: scrollController
);
Widget _listViewItem(BuildContext context, int index)
return new Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[50],
// border: Border.all(width:0.2,color: Colors.grey)
),
child: new Text('Item $index')
);
dart flutter
Can someone help me achieve custom Header(AppBar) and footer(bottomNavigationBar). The Header height resize min:20 to max:50 and Footer pinned(show/hide) according to user scroll. In most case, the header should be very much like AppBar/SliverAppbar.
The reason custom Header/Footer is that I need to draw widget shape over AppBar and bottomNavigationBar. And with the default AppBar/bottomNavigationBar there is no way to customized the index, so whatever widget shape i have in the body is alway stay in the back.
This is the code I am working on, its seem a little bit acceptable, would you help me improve?
import 'package:flutter/material.dart';
class CustomScrollOne extends StatefulWidget
@override
CustomScrollOneState createState() => new CustomScrollOneState();
class CustomScrollOneState extends State<CustomScrollOne> with SingleTickerProviderStateMixin
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
ScrollController scrollController;
double scrollOffset = 0.0;
double scrollOffsetLast = 0.0;
double upperSize = 50.0;
@override
initState()
scrollController = new ScrollController();
scrollController.addListener(updateOffset);
super.initState();
@override
dispose()
scrollController.removeListener(updateOffset);
scrollController.dispose();
super.dispose();
void updateOffset()
setState(()
scrollOffset = scrollController.offset;
);
scrollNotificationListener(ScrollNotification scrollNotification)
if (scrollNotification is ScrollUpdateNotification)
double minTop = 20.0;
double maxTop = 50.0;
if (scrollNotification.scrollDelta < 0)
// NOTE forward to normal
if (upperSize < maxTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(upperSize, maxTop);
else if (scrollNotification.scrollDelta > 0)
// NOTE reverse to large
if (upperSize > minTop)
double activePosition = scrollOffsetLast + upperSize - scrollOffset;
upperSize = (activePosition).clamp(minTop, upperSize);
else if (scrollNotification is ScrollEndNotification)
scrollOffsetLast = scrollController.offset;
@override
Widget build(BuildContext context)
return Scaffold(
key: scaffoldKey,
backgroundColor: Colors.white,
body: new SafeArea(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
top: upperSize,
left: 14,
right:14,
bottom: 50,
child: Container(
color: Colors.grey[200],
child: NotificationListener<ScrollNotification>(
onNotification: (e)=>scrollNotificationListener(e),
child: _listView(),
)
),
),
Positioned(
top: 0,
left: 50,
right: 50,
child: Container(
width: 300,
height: upperSize,
color: Colors.grey[100],
child: Text(upperSize.toString()),
),
),
Positioned(
top: 0,
left: 1,
bottom: 0,
child: Container(
width: 10,
height: upperSize,
color: Colors.red
)
)
]
)
)
);
Widget _listView()
return new ListView.builder(
itemCount: 60,
itemBuilder: _listViewItem,
controller: scrollController
);
Widget _listViewItem(BuildContext context, int index)
return new Container(
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.grey[50],
// border: Border.all(width:0.2,color: Colors.grey)
),
child: new Text('Item $index')
);
dart flutter
dart flutter
asked Mar 8 at 23:20
Khen Solomon LethilKhen Solomon Lethil
64
64
add a comment |
add a comment |
0
active
oldest
votes
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
);
);
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%2f55072339%2fflutter-custom-appbar-and-bottomnavigationbar%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f55072339%2fflutter-custom-appbar-and-bottomnavigationbar%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