class _ExampleSliverState extends State {
final controller = Get.find();
final sectionList = [];
final expandableListController = ExpandableListController();
final socketIoClient = SocketIoClient();
final collectionMap = <String, List>{}.obs;
final collections = SecuXCollectionsResponse(count: '', dataList: [], isCompleted: false).obs;
final isScanning = true.obs;
Hi, I use ExampleSliver code, sticky header does not work?
https://user-images.githubusercontent.com/1092021/179167268-aad59659-c2df-40be-bcae-5c3a6f7744f9.mp4
`import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:secuxtwallet/controller/gallery_controller.dart'; import 'package:secuxtwallet/model/secux_asset.dart'; import 'package:secuxtwallet/model/secux_collection.dart'; import 'package:secuxtwallet/util/socket_io_client.dart'; import 'package:sticky_and_expandable_list/sticky_and_expandable_list.dart';
class ExampleSliver extends StatefulWidget { @override _ExampleSliverState createState() => _ExampleSliverState(); }
class _ExampleSliverState extends State {
final controller = Get.find();
final sectionList = [];
final expandableListController = ExpandableListController();
final socketIoClient = SocketIoClient();
final collectionMap = <String, List>{}.obs;
final collections = SecuXCollectionsResponse(count: '', dataList: [], isCompleted: false).obs;
final isScanning = true.obs;
@override initState() { super.initState(); Future.delayed(Duration(seconds: 1), () async { await socketIoClient.getNFTCollectionsByOwner( collections, 'eth,bsc,polygon', '0xa96F57429c77352d625A3F57a94eC27C6c128f5D', '300'); await socketIoClient.getCollectionNFTsByOwner( collectionMap, isScanning, 'eth,bsc,polygon', '0xa96F57429c77352d625A3F57a94eC27C6c128f5D', '', '50');
}
@override Widget build(BuildContext context) { return sectionList.isEmpty ? const SafeArea(child: Scaffold(body: Text('1111'))) : SafeArea( child: Scaffold( body: CustomScrollView( slivers:[
SliverAppBar(
pinned: true,
floating: true,
expandedHeight: 50,
flexibleSpace: FlexibleSpaceBar(
title: Text(
"Sliver Example",
style: TextStyle(color: Colors.white),
),
),
iconTheme: IconThemeData(color: Colors.white),
),
SliverExpandableList(
builder: SliverExpandableChildDelegate<String, ExampleSection>(
sectionList: sectionList,
headerBuilder: _buildHeader,
itemBuilder: (context, sectionIndex, itemIndex, index) {
String item = sectionList[sectionIndex].items[itemIndex];
return ListTile(
leading: CircleAvatar(
child: Text("$index"),
),
title: Text(item),
);
},
),
),
],
),
),
);
}
Widget _buildHeader(BuildContext context, int sectionIndex, int index) { ExampleSection section = sectionList[sectionIndex]; return InkWell( child: Container( color: Colors.lightBlue, height: 48, padding: EdgeInsets.only(left: 20), alignment: Alignment.centerLeft, child: Text( section.header, style: TextStyle(color: Colors.white), )), onTap: () { //toggle section expand state setState(() { section.setSectionExpanded(!section.isSectionExpanded()); }); }); } }
class ExampleSection implements ExpandableListSection {
//store expand state.
late bool expanded;
//return item model list. late List items;
//example header, optional late String header;
@override List getItems() {
return items;
}
@override bool isSectionExpanded() { return expanded; }
@override void setSectionExpanded(bool expanded) { this.expanded = expanded; } } `