From 04b4b32daca91c6017f22e0c9f27010541a0d7f0 Mon Sep 17 00:00:00 2001 From: Tomasz Bogusz Date: Tue, 21 Jan 2020 17:20:05 +0100 Subject: [PATCH] CustomScrollView handling proposition --- .../components/peripheral_details_view.dart | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/example/lib/peripheral_details/components/peripheral_details_view.dart b/example/lib/peripheral_details/components/peripheral_details_view.dart index 1d3245d2..f91ce4ee 100644 --- a/example/lib/peripheral_details/components/peripheral_details_view.dart +++ b/example/lib/peripheral_details/components/peripheral_details_view.dart @@ -11,30 +11,31 @@ class PeripheralDetailsView extends StatelessWidget { Widget build(BuildContext context) { return CustomScrollView( slivers: [ - SliverSafeArea( - top: false, - sliver: SliverPadding( - padding: const EdgeInsets.all(8.0), - sliver: SliverToBoxAdapter( - child: BlocBuilder( - builder: (context, state) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - PropertyRow( - title: 'Identifier', - titleIcon: Icon(Icons.perm_device_information), - titleColor: Theme.of(context).primaryColor, - value: state.peripheral.id, - ), - _createServiceView(context, state) - ], - ); - }, - ), + SliverPadding( + padding: const EdgeInsets.all(8.0), + sliver: SliverToBoxAdapter( + child: BlocBuilder( + builder: (context, state) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + PropertyRow( + title: 'Identifier', + titleIcon: Icon(Icons.perm_device_information), + titleColor: Theme.of(context).primaryColor, + value: state.peripheral.id, + ), + ], + ); + }, ), ), ), + BlocBuilder( + builder: (context, state) { + return _createServiceView(context, state); + }, + ) ], ); } @@ -43,13 +44,11 @@ class PeripheralDetailsView extends StatelessWidget { BuildContext context, PeripheralDetailsState state, ) { - return Flexible( - fit: FlexFit.loose, - child: ListView.builder( - shrinkWrap: true, - itemCount: state.bleServiceStates.length, - itemBuilder: (context, index) => + return SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) => _createServiceTileView(context, state.bleServiceStates[index]), + childCount: state.bleServiceStates.length, ), ); }