Anonymous
Как я могу остановить прокрутку в SliverAppBar Flutter?
Сообщение
Anonymous » 27 окт 2024, 23:38
Панель приложений Sliver моего приложения уже окружена виджетом CustomScrollView. И на нем есть другие Щепки. Мне просто нужно было остановить прокрутку на панели приложения Sliver. Когда я нажимаю на Щепку, она прокручивает всю страницу. После добавления
NeverScrollableScrollPhysics () вся страница не может прокручиваться. Но мне нужно
остановить только
SliverAppBar .
Код: Выделить всё
body: CustomScrollView(
controller: _scrollController,
slivers: [
SliverAppBar(
systemOverlayStyle: SystemUiOverlayStyle.light,
backgroundColor: Theme.of(context).backgroundColor,
elevation: 1.0,
expandedHeight:
kIsWeb ? 0 : widthHeight * kProductDetail.height,
pinned: true,
floating: false,
leading: Padding(
padding: const EdgeInsets.all(8),
child: CircleAvatar(
backgroundColor: Theme.of(context)
.primaryColorLight
.withOpacity(0.7),
child: IconButton(
icon: Icon(
Icons.close,
color: Theme.of(context).primaryColor,
),
onPressed: () {
context
.read
()
.clearProductVariations();
Navigator.pop(context);
},
),
),
),
actions: [
if (widget.isLoading != true)
HeartButton(
product: product,
size: 20.0,
color: Theme.of(context).primaryColor,
),
Padding(
padding: const EdgeInsets.all(12),
child: CircleAvatar(
backgroundColor: Theme.of(context)
.primaryColorLight
.withOpacity(0.7),
child: IconButton(
icon: const Icon(Icons.more_vert, size: 19),
color: Theme.of(context).primaryColor,
onPressed: () => ProductDetailScreen.showMenu(
context,
widget.product,
isLoading: widget.isLoading,
),
),
),
),
],
flexibleSpace: kIsWeb
? const SizedBox()
: ProductImageSlider(
product: product,
onChange: (index) => setState(() {
_selectIndex = index;
}),
),
),
SliverList(
delegate: SliverChildListDelegate(
[
const SizedBox(height: 2),
if (kIsWeb)
ProductGallery(
product: widget.product,
selectIndex: _selectIndex,
),
Padding(
padding: const EdgeInsets.only(
top: 8.0,
bottom: 4.0,
left: 15,
right: 15,
),
child: product.type == 'grouped'
? const SizedBox()
: ProductTitle(product),
),
],
),
),
if (Services().widget.enableShoppingCart(
product.copyWith(isRestricted: false)))
renderProductInfo(),
if (!Services().widget.enableShoppingCart(
product.copyWith(isRestricted: false)) &&
product.shortDescription != null &&
product.shortDescription!.isNotEmpty)
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: ProductShortDescription(product),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(
// horizontal: 15.0,
vertical: 8.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15.0,
),
child: Column(
children: [
Services().widget.renderVendorInfo(product),
ProductDescription(product),
if (kProductDetail.showProductCategories)
ProductDetailCategories(product),
if (kProductDetail.showProductTags)
ProductTag(product),
Services()
.widget
.productReviewWidget(product.id!),
],
),
),
if (kProductDetail
.showRelatedProductFromSameStore &&
product.store?.id != null)
RelatedProductFromSameStore(product),
if (kProductDetail.showRelatedProduct)
RelatedProduct(product),
const SizedBox(height: 50),
],
),
),
),
],
),
Я просто хотел остановить всю прокрутку, когда нажимаю SliverAppBar.
Подробнее здесь:
https://stackoverflow.com/questions/739 ... ar-flutter
1730061509
Anonymous
Панель приложений Sliver моего приложения уже окружена виджетом CustomScrollView. И на нем есть другие Щепки. Мне просто нужно было остановить прокрутку на панели приложения Sliver. Когда я нажимаю на Щепку, она прокручивает всю страницу. После добавления [b]NeverScrollableScrollPhysics[/b]() вся страница не может прокручиваться. Но мне нужно [b]остановить[/b] только [b]SliverAppBar[/b]. [code] body: CustomScrollView( controller: _scrollController, slivers: [ SliverAppBar( systemOverlayStyle: SystemUiOverlayStyle.light, backgroundColor: Theme.of(context).backgroundColor, elevation: 1.0, expandedHeight: kIsWeb ? 0 : widthHeight * kProductDetail.height, pinned: true, floating: false, leading: Padding( padding: const EdgeInsets.all(8), child: CircleAvatar( backgroundColor: Theme.of(context) .primaryColorLight .withOpacity(0.7), child: IconButton( icon: Icon( Icons.close, color: Theme.of(context).primaryColor, ), onPressed: () { context .read () .clearProductVariations(); Navigator.pop(context); }, ), ), ), actions: [ if (widget.isLoading != true) HeartButton( product: product, size: 20.0, color: Theme.of(context).primaryColor, ), Padding( padding: const EdgeInsets.all(12), child: CircleAvatar( backgroundColor: Theme.of(context) .primaryColorLight .withOpacity(0.7), child: IconButton( icon: const Icon(Icons.more_vert, size: 19), color: Theme.of(context).primaryColor, onPressed: () => ProductDetailScreen.showMenu( context, widget.product, isLoading: widget.isLoading, ), ), ), ), ], flexibleSpace: kIsWeb ? const SizedBox() : ProductImageSlider( product: product, onChange: (index) => setState(() { _selectIndex = index; }), ), ), SliverList( delegate: SliverChildListDelegate( [ const SizedBox(height: 2), if (kIsWeb) ProductGallery( product: widget.product, selectIndex: _selectIndex, ), Padding( padding: const EdgeInsets.only( top: 8.0, bottom: 4.0, left: 15, right: 15, ), child: product.type == 'grouped' ? const SizedBox() : ProductTitle(product), ), ], ), ), if (Services().widget.enableShoppingCart( product.copyWith(isRestricted: false))) renderProductInfo(), if (!Services().widget.enableShoppingCart( product.copyWith(isRestricted: false)) && product.shortDescription != null && product.shortDescription!.isNotEmpty) SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0), child: ProductShortDescription(product), ), ), SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.symmetric( // horizontal: 15.0, vertical: 8.0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 15.0, ), child: Column( children: [ Services().widget.renderVendorInfo(product), ProductDescription(product), if (kProductDetail.showProductCategories) ProductDetailCategories(product), if (kProductDetail.showProductTags) ProductTag(product), Services() .widget .productReviewWidget(product.id!), ], ), ), if (kProductDetail .showRelatedProductFromSameStore && product.store?.id != null) RelatedProductFromSameStore(product), if (kProductDetail.showRelatedProduct) RelatedProduct(product), const SizedBox(height: 50), ], ), ), ), ], ), [/code] Я просто хотел остановить всю прокрутку, когда нажимаю SliverAppBar. [img]https ://i.sstatic.net/LZ76z.jpg[/img] Подробнее здесь: [url]https://stackoverflow.com/questions/73966133/how-can-i-stop-the-scroll-in-sliverappbar-flutter[/url]