#flutter #toolbar #floating #flutter-sliver
#флаттер #панель инструментов #плавающий #порхание-sliver
Вопрос:
Эта проблема типа ‘SliverAppBar’ не является подтипом проблемы с зависанием типа ‘PreferredSizeWidget’. возникла при попытке создать плавающую панель инструментов с использованием SilverAppBar в FLUTTER.
class AppTheme {
setAppBar(context, String title) {
return new AppBa(
floating: true,
pinned: true,
title: Text(title,
style: TextStyle(color: Colors.white),
textDirection: TextDirection.ltr),
flexibleSpace: Container(
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
hexToColor(themeColor1),
hexToColor(themeColor2),
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 1.0],
tileMode: TileMode.clamp),
),
),
);
}
}
Комментарии:
1. Вам нужно обернуть свои фрагменты в
CustomScrollView
Ответ №1:
Вы должны обернуть свой SliverAppBar
с CustomScrollView
:
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
...
),
...
]
);