Hide widgets when the silverappbar is scrolled up
I need to implement the following layouts.
When I scroll the layout up, it becomes like this.
I want the following effect when when scrolled up and I want the same effect as first image when the scrolled is down. I want the widgets with description and the review to disappear slowly when the page is scrolled up and reappear when the page is scrolled down.
I am using following code:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:mamham/ui/ReviewWidget.dart';
import 'package:flutter_image/network.dart';
import 'package:mamham/TestStrings.dart';
import 'package:mamham/model/Product.dart';
import 'package:mamham/model/Serializers.dart';
import 'package:mamham/ui/ProductSingle.dart';
import 'package:mamham/pages/cart/CartPage.dart';
import 'package:mamham/Strings.dart';
class RestaurantPage extends StatefulWidget {
RestaurantPage( {Key key, this.title} ) : super(key: key);
final String title;
@override
_RestaurantPageState createState() => _RestaurantPageState();
}
class _RestaurantPageState extends State<RestaurantPage> with SingleTickerProviderStateMixin {
ScrollController _scrollViewController;
AnimationController _bannerImageAnimationController;
Animation _bannerImageAnimation;
@override
void initState() {
super.initState();
_scrollViewController = ScrollController();
_bannerImageAnimationController = AnimationController(
duration: Duration(milliseconds: 2000),
vsync: this
);
_bannerImageAnimation = Tween(begin: 300.0, end: 150.0).animate(_bannerImageAnimationController)
..addListener((){
setState((){});
});
_bannerImageAnimationController.forward();
}
@override
void dispose() {
_scrollViewController.dispose();
_bannerImageAnimationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: size.height * 0.50,
pinned: true,
floating: false,
forceElevated: innerBoxIsScrolled,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => CartPage(title: Strings.PAGE_CART)));
},
)
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
height: size.height * 0.5,
child: Image(
fit: BoxFit.fill,
image: NetworkImageWithRetry('https://via.placeholder.com/300'),
),
),
title: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Mamham's Kitchen'),
Text('We believe in servingn"Food With Love"', style: TextStyle(color: Colors.white, fontSize: 12.0),),
ReviewWidget(reviewCount: 3.5, size: 12.0)
],
),
),
),
),
];
},
body: SafeArea(
bottom: true,
child: Column(
children: <Widget>[
// Product Listing
Expanded(
child: Container(
width: double.infinity,
child: GridView.count(
crossAxisCount: 2,
children: List.generate(100, (index) {
final parsedJson = json.decode(TestStrings.PRODUCT_JSON);
Product product = serializers.deserializeWith(Product.serializer, parsedJson);
return ProductSingle(product: product);
}),
)
)
)
],
)
)
),
);
}
}
flutter
add a comment |
I need to implement the following layouts.
When I scroll the layout up, it becomes like this.
I want the following effect when when scrolled up and I want the same effect as first image when the scrolled is down. I want the widgets with description and the review to disappear slowly when the page is scrolled up and reappear when the page is scrolled down.
I am using following code:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:mamham/ui/ReviewWidget.dart';
import 'package:flutter_image/network.dart';
import 'package:mamham/TestStrings.dart';
import 'package:mamham/model/Product.dart';
import 'package:mamham/model/Serializers.dart';
import 'package:mamham/ui/ProductSingle.dart';
import 'package:mamham/pages/cart/CartPage.dart';
import 'package:mamham/Strings.dart';
class RestaurantPage extends StatefulWidget {
RestaurantPage( {Key key, this.title} ) : super(key: key);
final String title;
@override
_RestaurantPageState createState() => _RestaurantPageState();
}
class _RestaurantPageState extends State<RestaurantPage> with SingleTickerProviderStateMixin {
ScrollController _scrollViewController;
AnimationController _bannerImageAnimationController;
Animation _bannerImageAnimation;
@override
void initState() {
super.initState();
_scrollViewController = ScrollController();
_bannerImageAnimationController = AnimationController(
duration: Duration(milliseconds: 2000),
vsync: this
);
_bannerImageAnimation = Tween(begin: 300.0, end: 150.0).animate(_bannerImageAnimationController)
..addListener((){
setState((){});
});
_bannerImageAnimationController.forward();
}
@override
void dispose() {
_scrollViewController.dispose();
_bannerImageAnimationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: size.height * 0.50,
pinned: true,
floating: false,
forceElevated: innerBoxIsScrolled,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => CartPage(title: Strings.PAGE_CART)));
},
)
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
height: size.height * 0.5,
child: Image(
fit: BoxFit.fill,
image: NetworkImageWithRetry('https://via.placeholder.com/300'),
),
),
title: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Mamham's Kitchen'),
Text('We believe in servingn"Food With Love"', style: TextStyle(color: Colors.white, fontSize: 12.0),),
ReviewWidget(reviewCount: 3.5, size: 12.0)
],
),
),
),
),
];
},
body: SafeArea(
bottom: true,
child: Column(
children: <Widget>[
// Product Listing
Expanded(
child: Container(
width: double.infinity,
child: GridView.count(
crossAxisCount: 2,
children: List.generate(100, (index) {
final parsedJson = json.decode(TestStrings.PRODUCT_JSON);
Product product = serializers.deserializeWith(Product.serializer, parsedJson);
return ProductSingle(product: product);
}),
)
)
)
],
)
)
),
);
}
}
flutter
add a comment |
I need to implement the following layouts.
When I scroll the layout up, it becomes like this.
I want the following effect when when scrolled up and I want the same effect as first image when the scrolled is down. I want the widgets with description and the review to disappear slowly when the page is scrolled up and reappear when the page is scrolled down.
I am using following code:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:mamham/ui/ReviewWidget.dart';
import 'package:flutter_image/network.dart';
import 'package:mamham/TestStrings.dart';
import 'package:mamham/model/Product.dart';
import 'package:mamham/model/Serializers.dart';
import 'package:mamham/ui/ProductSingle.dart';
import 'package:mamham/pages/cart/CartPage.dart';
import 'package:mamham/Strings.dart';
class RestaurantPage extends StatefulWidget {
RestaurantPage( {Key key, this.title} ) : super(key: key);
final String title;
@override
_RestaurantPageState createState() => _RestaurantPageState();
}
class _RestaurantPageState extends State<RestaurantPage> with SingleTickerProviderStateMixin {
ScrollController _scrollViewController;
AnimationController _bannerImageAnimationController;
Animation _bannerImageAnimation;
@override
void initState() {
super.initState();
_scrollViewController = ScrollController();
_bannerImageAnimationController = AnimationController(
duration: Duration(milliseconds: 2000),
vsync: this
);
_bannerImageAnimation = Tween(begin: 300.0, end: 150.0).animate(_bannerImageAnimationController)
..addListener((){
setState((){});
});
_bannerImageAnimationController.forward();
}
@override
void dispose() {
_scrollViewController.dispose();
_bannerImageAnimationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: size.height * 0.50,
pinned: true,
floating: false,
forceElevated: innerBoxIsScrolled,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => CartPage(title: Strings.PAGE_CART)));
},
)
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
height: size.height * 0.5,
child: Image(
fit: BoxFit.fill,
image: NetworkImageWithRetry('https://via.placeholder.com/300'),
),
),
title: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Mamham's Kitchen'),
Text('We believe in servingn"Food With Love"', style: TextStyle(color: Colors.white, fontSize: 12.0),),
ReviewWidget(reviewCount: 3.5, size: 12.0)
],
),
),
),
),
];
},
body: SafeArea(
bottom: true,
child: Column(
children: <Widget>[
// Product Listing
Expanded(
child: Container(
width: double.infinity,
child: GridView.count(
crossAxisCount: 2,
children: List.generate(100, (index) {
final parsedJson = json.decode(TestStrings.PRODUCT_JSON);
Product product = serializers.deserializeWith(Product.serializer, parsedJson);
return ProductSingle(product: product);
}),
)
)
)
],
)
)
),
);
}
}
flutter
I need to implement the following layouts.
When I scroll the layout up, it becomes like this.
I want the following effect when when scrolled up and I want the same effect as first image when the scrolled is down. I want the widgets with description and the review to disappear slowly when the page is scrolled up and reappear when the page is scrolled down.
I am using following code:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:mamham/ui/ReviewWidget.dart';
import 'package:flutter_image/network.dart';
import 'package:mamham/TestStrings.dart';
import 'package:mamham/model/Product.dart';
import 'package:mamham/model/Serializers.dart';
import 'package:mamham/ui/ProductSingle.dart';
import 'package:mamham/pages/cart/CartPage.dart';
import 'package:mamham/Strings.dart';
class RestaurantPage extends StatefulWidget {
RestaurantPage( {Key key, this.title} ) : super(key: key);
final String title;
@override
_RestaurantPageState createState() => _RestaurantPageState();
}
class _RestaurantPageState extends State<RestaurantPage> with SingleTickerProviderStateMixin {
ScrollController _scrollViewController;
AnimationController _bannerImageAnimationController;
Animation _bannerImageAnimation;
@override
void initState() {
super.initState();
_scrollViewController = ScrollController();
_bannerImageAnimationController = AnimationController(
duration: Duration(milliseconds: 2000),
vsync: this
);
_bannerImageAnimation = Tween(begin: 300.0, end: 150.0).animate(_bannerImageAnimationController)
..addListener((){
setState((){});
});
_bannerImageAnimationController.forward();
}
@override
void dispose() {
_scrollViewController.dispose();
_bannerImageAnimationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: size.height * 0.50,
pinned: true,
floating: false,
forceElevated: innerBoxIsScrolled,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => CartPage(title: Strings.PAGE_CART)));
},
)
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
height: size.height * 0.5,
child: Image(
fit: BoxFit.fill,
image: NetworkImageWithRetry('https://via.placeholder.com/300'),
),
),
title: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Mamham's Kitchen'),
Text('We believe in servingn"Food With Love"', style: TextStyle(color: Colors.white, fontSize: 12.0),),
ReviewWidget(reviewCount: 3.5, size: 12.0)
],
),
),
),
),
];
},
body: SafeArea(
bottom: true,
child: Column(
children: <Widget>[
// Product Listing
Expanded(
child: Container(
width: double.infinity,
child: GridView.count(
crossAxisCount: 2,
children: List.generate(100, (index) {
final parsedJson = json.decode(TestStrings.PRODUCT_JSON);
Product product = serializers.deserializeWith(Product.serializer, parsedJson);
return ProductSingle(product: product);
}),
)
)
)
],
)
)
),
);
}
}
flutter
flutter
asked Nov 18 '18 at 5:55
Sagar TamangSagar Tamang
384113
384113
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%2f53358295%2fhide-widgets-when-the-silverappbar-is-scrolled-up%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%2f53358295%2fhide-widgets-when-the-silverappbar-is-scrolled-up%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