sarina
2 سال پیش توسط sarina مطرح شد
1 پاسخ

searchappbar وsliverappbar برای ورژن جدید دارت

سلام من با ورژن جدید دارت searchapp bar اینجوری نوشتم ارور داد میدونید چجوری باید بنویسم ویدیو زیاد دیدم گیج شدم
with SingleTickerProviderStateMixin {
late TabController tabController;
late Map<String, SliverAppBar> appBarList;
String currentAppBar = 'mainAppBar';

@override
void initState() {
// TODO: implement initState
super.initState();
tabController = new TabController(initialIndex: 1, length: 4, vsync: this);

SliverAppBar mainAppBar = new SliverAppBar(
  title: new Text('واتس اپ'),
  pinned: true,
  elevation: 5,
  bottom: new TabBar(
    controller: tabController,
    indicatorColor: Colors.white,
    tabs: <Widget>[
      new Tab(icon: new Icon(Icons.camera_alt)),
      new Tab(text: " چت ها"),
      new Tab(text: "وضعیت"),
      new Tab(text: "تماس ها"),
    ],
  ),
  actions: <Widget>[
    new Icon(Icons.search),
    new Padding(padding: EdgeInsets.symmetric(horizontal: 5)),
    new PopupMenuButton<String>(onSelected: (String choice) {
      print(choice);
    }, itemBuilder: (BuildContext context) {
      return [
        new PopupMenuItem(
            value: 'new_group',
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[new Text('گروه جدید')],
            )),
        new PopupMenuItem(
            value: 'setting',
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[new Text('تنظیمات')],
            ))
      ];
    })
  ],
);

appBarList = <String, SliverAppBar>{
  'mainAppBar': mainAppBar,
  'searchAppBar': mainAppBar
};

}

@override
Widget build(BuildContext context) {
return new Scaffold(
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[appBarList[currentAppBar]];
},
خط اخر ارور میده
The element type 'SliverAppBar?' can't be assigned to the list type 'Widget'.