Closed MarceloRab closed 5 years ago
@MarceloRab could you provide code sample?
class MyEvestsListDayScroll extends StatefulWidget {
@override _MyEvestsListDayScrollState createState() => _MyEvestsListDayScrollState(); }
class MyEvestsListDayScrollState extends State
//DateTime dayEvents;
@override
void initState() {
//maxCount = widget.listEventDay.length;
//maxCount = _compromissoBloc.eventsDay.length;
_compromissoBloc = HomeModule.to.bloc
super.initState();
}
@override Widget build(BuildContext context) {
return StreamBuilder<DateTime>(
stream: _compromissoBloc.dayEscolhidoStream,
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(
child: CircularProgressIndicator(),
);
else
return InfiniteList(
// scrollDirection: Axis.horizontal,
minChildCount: minCount,
maxChildCount: maxCount,
anchor: 0.0,
builder: (BuildContext context, int index) {
return InfiniteListItem(
initialHeaderBuild: true,
minOffsetProvider: (StickyState<int> state) => 50,
//headerAlignment: HeaderAlignment.bottomLeft,
headerStateBuilder:
(BuildContext context, StickyState<int> state) {
return Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.orange.withOpacity(state.position != 0
? 1 - (state.position)
: (1 - state.position).abs()),
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 2,
offset: Offset(2.0, 3.0),
spreadRadius: 2.0)
],
),
alignment: Alignment.center,
margin: EdgeInsets.only(left: 6, top: 20),
padding: EdgeInsets.all(12),
width: 70,
height: 80,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
//"${MyDateHelper.setDiaDate(_compromissoBloc.eventsFullList[index].id)}",
"${MyDateHelper.setDiaDate(snapshot.data)}",
style: TextStyle(
fontSize: 20,
fontFamily: 'Roboto Mono',
fontWeight: FontWeight.bold),
),
Text(
//"${MyDateHelper.setDiaDate(_compromissoBloc.eventsFullList[index].id)}",
"${MyDateHelper.setMonthCalendar(
date: snapshot.data,
).substring(0, 3)}",
style: TextStyle(
fontSize: 18,
fontFamily: 'Roboto Mono',
),
),
],
),
);
},
contentBuilder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.all(
Radius.circular(20))),
height:
(34 * _compromissoBloc.eventsDay.length).toDouble(),
margin: EdgeInsets.only(left: 50, top: 10, right: 10),
width: MediaQuery.of(context).size.width - 60,
child: Align(
alignment: Alignment.topLeft,
child: Column(
//mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children:
_compromissoBloc.eventsDay.map<Widget>((event) {
return Container(
margin: EdgeInsets.only(left: 40, top: 10),
child: Text(
"Content ${event as String}",
style: TextStyle(
color: Colors.white, fontSize: 18),
),
);
}).toList(),
),
),
);
},
);
});
});
} }
Thanks in advance for the support.
I commented on the part where the error occurs. => scrollDirection: Axis.horizontal.
Could you share an example where - scrollDirection: Axis.horizontal is used?
I am Brazilian.
@MarceloRab sure - https://github.com/TatsuUkraine/flutter_sticky_infinite_list_example this is an example app, you can switch horizontal and vertical list there in left sidenav
Thank you. I'm going to study and ask for help if you need it.
Congratulations for the good work.
@MarceloRab btw, I noticed that you going to render just 1 element with a bunch of data inside, so you can try to use just SingleChildScrollView with this widget inside https://github.com/TatsuUkraine/flutter_sticky_infinite_list/blob/master/lib/widget.dart#L363
https://github.com/TatsuUkraine/flutter_sticky_infinite_list#need-more-override-ok-not-tested
That's right, I'm in testing mode. Already tested with many elements and in vertical mode flowed correctly.
The above error also occurred with too many elements. But I need to study the above example in more detail.
@MarceloRab btw, could you also provide flutter doctor
info?
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel master, v1.9.8-pre.106, on Microsoft Windows [versão 10.0.18362.295], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [√] Android Studio (version 3.5) [√] VS Code (version 1.37.0) [!] Connected device ! No devices available
! Doctor found issues in 1 category.
@MarceloRab ok, I think I found where problem is. Try to specify ScrollController() in InfiniteList as tmp solution (InfiniteList
class has controller
property for this). I'm going to investigate this further, but it seems that Flutter doesn't create controller for scroll axis horizontal
Which is strange, since it creates controller for vertical scroll by default, if it's not specified
@TatsuUkraine My list is inside a NotificationListener
@MarceloRab it's just a temp if you need to make it work quickly) I will push new release with fix for this issue tomorrow
@MarceloRab Or you can use this branch for now position-listener-bug
@TatsuUkraine Everything was ok. As used in a PageView, there is no need for horizontal movement. But your orientation of not setting controller = null solved the problem in my tests. Horizontal scrolling worked as expected after the change. Thank you very much. You can close the topic.
@MarceloRab new version is available (1.2.3) on pub.dart. This version contains fixes for this issue with a horizontal scroll. Also it fixes standalone StickyListItem
usage inside SingleChildScrollView
.
Also Example project was updated with an example of StickyListItem
usage
The following NoSuchMethodError was thrown building _StickySliverListItem(dependencies:
I/flutter (31517): [MediaQuery], state: _StickySliverListItemState#030fb):
I/flutter (31517): The method 'addListener' was called on null.
I/flutter (31517): Receiver: null
I/flutter (31517): Tried calling: addListener(Closure: () => void from Function 'markNeedsPaint':.)