0
Widget build(BuildContext context) {
return Scaffold(
  body: NestedScrollView(
    headerSliverBuilder: (context, innerBoxIsScrolled) =>
    SliverAppBar(
    title: Text('hide appbar'),
      centerTitle: true,
      leading: IconButton(
      icon: Icon(Icons.menu),
      onPressed: () {},
      ),
      actions: [
      IconButton(
      icon: Icon(Icons.search),
      onPressed: () {},
      )
      ],
//backgroundColor: Colors.purple,
      flexibleSpace: Container(
      decoration: BoxDecoration(
      gradient: LinearGradient(
      colors: [Colors.purple, Colors.red],
      begin: Alignment.bottomRight,
      end: Alignment.topLeft,
    ),
  ),
),
    ),

I fixed most of the issue but there is one last thing that keeps me run this code on my device. The error is The return type 'SliverAppBar' isn't a 'List<Widget>', as required by the closure's context. My body is wrapped with Singlechildscrollview. Is this why the NestedScrollView isn't working? Thanks for you help in advance

1 Answer 1

1

You need to return List of widgets from headerSliverBuilder. SliverAppBar is a single widget and returning like this, showing the error. You can wrap it with List.

headerSliverBuilder: (context, innerBoxIsScrolled) 
         => [ SliverAppBar(...) ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.