Comments (13)
I will add that in the next release. Thank you for reporting.
from flutter-expandable.
class MyItem extends StatefulWidget {
final ItemModel _item;
final bool expanded;
const MyItem(this._item, {this.expanded = false});
@override
_MyItemState createState() => _MyItemState();
}
class _MyItemState extends State<MyItem> {
ExpandableController _controller;
@override
void initState() {
super.initState();
_controller = new ExpandableController(initialExpanded: widget.expanded);
_controller.addListener(_onToggle);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
void didUpdateWidget(MyItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.expanded) {
_controller.expanded = true;
}
}
_onToggle(){
print("Is expanded: ${_controller.expanded}");
}
@override
Widget build(BuildContext context) =>
ExpandableTheme(
data: ExpandableThemeData(
headerAlignment: ExpandablePanelHeaderAlignment.center),
child: ExpandablePanel(
controller: _controller,
header: Text(widget._item.title, style: Themes.baseRegularGrey),
expanded: Text(widget._item.content)));
}
from flutter-expandable.
Any news on this feature?
from flutter-expandable.
As @TomTom101 suggested, this can be achieved with the controller addListener
callback.
class _MyPageState extends State<MyPage> {
...
final ExpandableController _infoPanelController = ExpandableController(initialExpanded: false);
...
@override
void initState() {
_infoPanelController.addListener(() {
if (_infoPanelController.expanded) {
setState(() {
...
});
} else {
setState(() {
...
});
}
});
super.initState();
}
}
from flutter-expandable.
from flutter-expandable.
I just wanted to let you know that without this callback this awesome library is useless. I spent a few hours to implement it in my code and now I have to migrate to flutter's Expansion list because this library is missing the callback. This callback is so essential and obvious that I thought you had implemented it when I red your Pub.dev page but then I realized I only wasted a few hours.
Thank you.
from flutter-expandable.
ExpandableController not good idea for multi panel,
onExpanded on every panel can be solved
from flutter-expandable.
@TomTom101 You can pass controller and add listener to controller. Then in onChange
function check _controller.expanded
flag
from flutter-expandable.
What kind of controller? Can you give a quick example? Thanks!
from flutter-expandable.
Hey there, I have a question related to this. I am using the Provider package and I was trying to make it so that when an item is expanded it changes the parent's flex value for it's width.
Below is essentially how I have it set up, but I keep getting the following error (Below the code): I am guessing that it is because it is trying to change the value/expand the parent but the expanding widget is animating to actually expand still (or something along these lines). Is there a way to know when it has completed the expanding, or to do what I am trying to do before the expanding begins? If there are any recommendations, I would greatly appreciate it.
Thanks,
-MH
This is part of the Provider notifier I am using for this.
class ChangeLogDataProvider with ChangeNotifier {
bool _changeLogExpanded = false;
void setExpanded(bool expand) {
_changeLogExpanded = expand;
notifyListeners();
}
bool get isExpanded => _changeLogExpanded;
This is part of the widget display for the expanding items where I am setting the expansion value based on the controller.expanded value.
final changeLogData = Provider.of<ChangeLogDataProvider>(context);
builder: (context, collapsed, expanded) {
var controller = ExpandableController.of(context);
controller.expanded ? changeLogData.setExpanded(true) : changeLogData.setExpanded(false);
}
This is part of the parent widget in which I am trying to set the flex value based on the value in the Provider notifier, which was set from the controller.expanded value above.
final changeLogData = Provider.of<ChangeLogDataProvider>(context);
Flexible(
flex: (changeLogData.isExpanded) ? 3 : 1,
child: AnimatedSize(
curve: Curves.easeIn,
duration: new Duration(milliseconds: 300),
vsync: this,
child: ChangeLogList(),
)),
The following assertion was thrown while dispatching notifications for ChangeLogDataProvider:
setState() or markNeedsBuild() called during build.
This _InheritedProviderScope<ChangeLogDataProvider> widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was: _InheritedProviderScope<ChangeLogDataProvider>
value: Instance of 'ChangeLogDataProvider'
listening to value
The widget which was currently being built when the offending call was made was: ExpandablePanel
dirty
dependencies: [_ExpandableControllerNotifier]
When the exception was thrown, this was the stack:
#0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:4171:11)
#1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4186:6)
#2 _InheritedProviderScopeElement.markNeedsNotifyDependents (package:provider/src/inherited_provider.dart:426:5)
#3 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:207:21)
#4 ChangeLogDataProvider.setWidth (package:searcher_installer_go/data/provider/changelog_provider.dart:20:5)
...
The ChangeLogDataProvider sending notification was: Instance of 'ChangeLogDataProvider'
════════════════════════════════════════════════════════════════════════════════════════════════════
from flutter-expandable.
Hi @aryzhov, can you provide an idea when this feature is coming up,
from flutter-expandable.
I will add that in the next release. Thank you for reporting.
it is November now but it is still not resolved :(
from flutter-expandable.
I have create a PR about this because i need this functionality too. i can achieve this with listen to ExpandableController
but when it comes to List, i think that's a bad approach,.
from flutter-expandable.
Related Issues (20)
- How to implement a "Should Show Expand" method?
- How to set the initial state to expanded? HOT 1
- Is there any methods to create nested ExpandablePanels (for example like with ExpandedTile)
- Logging when expand and collapsed with too much child
- How does the icon of each item change direction when I click on each item separately?
- iOS - overlapped text HOT 2
- Opaque HitTestBehavior option for GestureDetector when useInkWell is false
- Expanded At First HOT 1
- Dart not supporting your "expanded" getter and setter method overloading.
- Example not compiling
- dismiss keyboard when click on expand/collapse icon or header
- Remember if the panel was expanded. HOT 2
- bug on changing the orientation of the screen
- Actively maintained? HOT 1
- how to set margin bottom, it's too big without any reason
- how to use this in gridview?
- Expand arrow is dark when default dark theme HOT 2
- huge performance issue HOT 1
- Remove splash HOT 1
- ExpandableController toggle crash issue caused by impeller in iOS
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 flutter-expandable.