Comments (34)
@WieFel updateBackLayerHeight
idea seems like a workaround.
Proper fix would be to not set headerHeight
etc, on initState
and do it instead in build
itself, I am working on this. Meanwhile you can provide with the workaround to @proninyaroslav
from backdrop.
@hassanbasanjide I will look into this during weekend.
from backdrop.
I will have a look asap and provide you with a feature branch you can use meanwhile...
from backdrop.
I have worked on the fix in branch fix/stickyHeaderWhenBackLayerUpdated
@proninyaroslav @amebrahimi @hassanbasanjide Please test the fix by pointing to this branch in pubspec.yaml
@WieFel Can you also test this changes against demo app? And I don't think we need to go for workaround now!
from backdrop.
This fix has landed in v0.4.5
on pub.dev
@hassanbasanjide @proninyaroslav Check yourself on repo and pub README!!
from backdrop.
@WieFel Thank you I will look at this but I'm looking forward to see this in production
from backdrop.
Could you provide a simple code snippet with what you are trying to achieve?
Why do you need to change the height dynamically via BLOC?
Maybe you should have a look at the stickyFrontLayer
property, which allows to automatically adapt the height to the back layer content.
from backdrop.
@hassanbasanjide It could be because of flutter not redrawing the BackdropScaffold
. Does setting UniqueKey
to BackdropScaffold
solve the issue?
As @WieFel suggested, share some code that could reproduce the bug.
from backdrop.
@WieFel stickyfrontlayer is true. and backlayers have a different height but nothing Changed. ;(
the space of back layer witch have no content is blue.
actually the header height just accept one height at begin.
@OverRide
Widget build(BuildContext context) {
@OverRide
void changeController() {
setState(() {
expanded ? _controller.forward() : _controller.reverse();
expanded = !expanded;
});
}
return BlocBuilder<StoreBackDropControllerBloc,
StoreBackDropControllerState>(
builder: (context, state) {
return BackdropScaffold(
stickyFrontLayer: true,
resizeToAvoidBottomInset: false,
appBar: state.when(
initial: (state) => storeNormalAppBar(
context: context,
targetFunction: () => changeController(),
),
searchPage: (state) => searchAppBar(
context: context,
targetFunction: () => changeController(),
),
filterPage: (state) => filterAppBar(
context: context,
targetFunction: () => changeController(),
),
),
frontLayer: StorePageSubScreenForm(),
subHeaderAlwaysActive: false,
frontLayerBorderRadius: BorderRadius.circular(0),
controller: _controller,
backLayer: state.when(
initial: (state) => SearchScreen(),
searchPage: (state) => SearchScreen(),
filterPage: (state) => FiltersScreen()),
);
},
);
}
}
from backdrop.
from backdrop.
@daadu i need some things like images. now what is your recommend?
from backdrop.
The problem is you can't change the key which is created for the backdrop. And because of that when the backdrop changes in any state, the widget isn't being recreated and the height of the widget is not being redrawn. @daadu I can't set a new UniqueKey upon changing state because the BackdropScaffold doesn't accepts Key. And if I change the parent's key when the state changes It the backLayer Isn't being drawn.
from backdrop.
@hassanbasanjide I had a look at it but it is still not enough code for me to reproduce the issue completely.
I pushed a version of BackdropScaffold
containing the key
property to the branch scaffold_key.
You can try to import it into your project like so (in your pubspec.yaml
):
dependencies:
backdrop:
git:
url: git@github.com:fluttercommunity/backdrop.git
ref: scaffold_key
Try setting a key on BackdropScaffold
and tell us if that solves your problem. If yes, we can apply the changes to the master channel of backdrop.
from backdrop.
@hassanbasanjide let un know if it works
from backdrop.
@hassanbasanjide Any update?
from backdrop.
@WieFel I want to use this
dependencies:
backdrop:
git:
url: [email protected]:fluttercommunity/backdrop.git
ref: scaffold_key
but I can't is there any permissions you have to give or something?
from backdrop.
url: [email protected]:fluttercommunity/backdrop.git
@amebrahimi maybe try url: https://github.com/fluttercommunity/backdrop.git
Does that work? Which error do you get?
from backdrop.
@daadu
I faced a similar problem. Calling setState
changes the height of the widget, but this doesn't affect the height of the back layer, it stays the same. I also tried the scaffold_key
branch, but it has similar behavior.
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String text = "Back Layer 1";
double height = 100;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Backdrop Example",
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: BackdropScaffold(
appBar: BackdropAppBar(
title: Text("Backdrop Example"),
stickyFrontLayer: true,
actions: <Widget>[
LayoutBuilder(
builder: (context, constraints) => IconButton(
icon: Icon(Icons.terrain),
onPressed: () {
setState(() {
height = 200;
text = "Back layer 2";
Backdrop.of(context).fling();
});
},
),
),
],
),
backLayer: Container(
height: height,
child: Center(child: Text(text)),
),
frontLayer: Center(
child: Text("Front Layer"),
),
),
);
}
}
from backdrop.
from backdrop.
@proninyaroslav thanks for the code example.
The problem is that changing the height of the back layer only affects the back layer itself and its children. The problem here is that BackdropScaffold
(which is the parent of back layer) isn't updated, not even using the scaffold_key
branch.
The original idea was that the back layer would keep its height always the same.
@daadu to solve the problem we could add a callback updateBackLayerHeight()
to BackdropScaffold
which could be called if the height of the back layer changes. What do you think?
from backdrop.
@WieFel
Thank you for response. Is there a workaround for now? I would like to use a backdrop in app, like a hybrid of Navigation Drawable + Top Sheet (this concept is in the official guideline).
from backdrop.
Thank you for response. Is there a workaround for now? I would like to use a backdrop in app, like a hybrid of Navigation Drawable + Top Sheet (this concept is in the official guideline).
@proninyaroslav Once this is fixed, can you work on adding this use case to the demo app (flutter app to demonstrate all use cases in MDG for backdrop), it is under demo/
dir?
Or @WieFel have we already covered it?
@proninyaroslav Can you post the screenshot form MDG that explains this use case?
from backdrop.
@hassanbasanjide Sorry, for being 2 months late. The problem only got clear when @proninyaroslav posted a reproduceable code.
from backdrop.
@daadu
Yes, now it works as expected. Thank you.
Once this is fixed, can you work on adding this use case to the demo app (flutter app to demonstrate all use cases in MDG for backdrop), it is under
demo/
dir?
Ok, let me know.
from backdrop.
Or @WieFel have we already covered it?
Well there is no specific use case for targeting a changing back layer height in the material design guidelines.
Not sure if we should add this as separate use case to demo app. In my opinion the dynamic height of the back layer is actually a feature that one would already expect from this package... @daadu
from backdrop.
@WieFel
This is mentioned here, in the "Revealing the back layer" section https://material.io/components/backdrop#behavior
The height of the back layer is based on the size of its content.
from backdrop.
@daadu @WieFel
Is it possible to animate the transition between the back layers (size changing) when one of the layers is already revealed? In other words, moving to a second back layer with a different height makes the front layer lower/upper, but without any animation.
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String text = "Back Layer 1";
double height = 100;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Backdrop Example",
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: BackdropScaffold(
appBar: BackdropAppBar(
title: Text("Backdrop Example"),
actions: <Widget>[
LayoutBuilder(
builder: (context, constraints) => IconButton(
icon: Icon(Icons.terrain),
onPressed: () {
setState(() {
height = 200;
text = "Back layer 2";
});
},
),
),
],
),
stickyFrontLayer: true,
backLayer: Container(
height: height,
child: Center(child: Text(text)),
),
frontLayer: Center(
child: Text("Front Layer"),
),
),
);
}
}
from backdrop.
@daadu thank you for your response. ;)
from backdrop.
@daadu @WieFel
Is it possible to animate the transition between the back layers (size changing) when one of the layers is already revealed? In other words, moving to a second back layer with a different height makes the front layer lower/upper, but without any animation.
@proninyaroslav Use AnimatedSize
widget around backLayer
from backdrop.
@daadu
This idea came to me initially, but it doesn't work as expected:
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
String text = "Back Layer 1";
double height = 100;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Backdrop Example",
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: BackdropScaffold(
appBar: BackdropAppBar(
title: Text("Backdrop Example"),
actions: <Widget>[
LayoutBuilder(
builder: (context, constraints) => IconButton(
icon: Icon(Icons.terrain),
onPressed: () {
setState(() {
height = 200;
text = "Back Layer 2";
});
},
),
),
],
),
stickyFrontLayer: true,
backLayer: AnimatedSize(
vsync: this,
duration: Duration(milliseconds: 200),
child: Container(
height: height,
child: Center(child: Text(text)),
),
),
frontLayer: Center(
child: Text("Front Layer"),
),
),
);
}
}
from backdrop.
@proninyaroslav Can you raise this as a new issue? I think this should be resolved. What about you @WieFel ?
from backdrop.
This is working:
backLayer: NotificationListener<SizeChangedLayoutNotification>(
onNotification: (notification) {
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
setState(() {});
});
return true;
},
child: SizeChangedLayoutNotifier(
child: AnimatedSize(
vsync: this,
duration: Duration(milliseconds: 200),
child: Container(
height: height,
child: Center(child: Text(text)),
),
),
),
),
from backdrop.
The issue is _MeasureSize
is notifying sizeChange only at start of animation. I think using SizeChangedLayoutNotifier
inside _MesureSize
should work out of the box.
from backdrop.
Closing this issue, this issue will be further tracked at #55
from backdrop.
Related Issues (20)
- Merge example and demo project HOT 5
- Abstract out "backdrop core" from `BackdropScaffold`
- Add a shadow to the front layer
- Custom shape on the front layer HOT 7
- How to show back layer without scrim on front? HOT 5
- Slivers AppBar HOT 7
- cannot paste if backdrop is revealed HOT 6
- I can't get edge swipe to go back to work with BackdropScaffold. Any helpful tips? HOT 1
- flutter beta: SchedulerBinding is now null-safe HOT 2
- BoxShadow on front layer HOT 3
- Backdrop is not compiling after upgrading to Flutter 3.10 HOT 2
- En Flutter 3.10 no compila Por 2 Lineas en el Widget AppBar (brightness y textTheme), las cuales estan en desuso pero el compilador las toma en cuenta, eliminando esas 2 lines el paquete funciona perfectamente HOT 3
- Variable to know if back layer is expanded or collapsed HOT 1
- Manually opening Backdrop HOT 9
- Pressing Back button cause visible frontLayer HOT 10
- Reveal backlayer with natural gestures HOT 1
- Make a parameter out of front layer elevation HOT 6
- BackdropScaffold usage gif example needs an update! HOT 1
- Avoid SubHeader spawn on top of Front Layer HOT 2
- Use AppBar.SystemOverlayStyle instead of AppBar.Brightness HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backdrop.