I want to animate a SliverAppBar that is defined in a NestedScrollView. I want to have the same animation Whatsapp has while scrolling to the camera tab but using Animated Widgets as Slivers parent is forbidden. how can i achieve that? here is an expensive way to do it but it's not performance-friendly
Asked
Active
Viewed 568 times
1 Answers
1
You can set your app bar like this to hide AppBar when the user scrolls the view
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const title = 'Floating App Bar';
return MaterialApp(
title: title,
home: Scaffold(
// No appbar provided to the Scaffold, only a body with a
// CustomScrollView.
body: CustomScrollView(
slivers: [
// Add the app bar to the CustomScrollView.
const SliverAppBar(
// Provide a standard title.
title: Text(title),
// Allows the user to reveal the app bar if they begin scrolling
// back up the list of items.
floating: true,
// Display a placeholder widget to visualize the shrinking size.
flexibleSpace: Placeholder(),
// Make the initial height of the SliverAppBar larger than normal.
expandedHeight: 200,
),
// Next, create a SliverList
SliverList(
// Use a delegate to build items as they're scrolled on screen.
delegate: SliverChildBuilderDelegate(
// The builder function returns a ListTile with a title that
// displays the index of the current item.
(context, index) => ListTile(title: Text('Item #$index')),
// Builds 1000 ListTiles
childCount: 1000,
),
),
],
),
),
);
}
}

chirag kalathiya
- 41
- 3
-
This is not really what i want to acheive. but anyway, thanks. – Mohamed Yahia Aug 20 '21 at 04:03