Colapsing Toolbar with Sliver In Flutter

Colapsing Toolbar with Sliver In Flutter

main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primaryColor: Colors.red),
      home: Scaffold(
        body: CustomScrollView(
          slivers: <Widget>[
            SliverAppBar(
              expandedHeight: 200,
              pinned: true,
              flexibleSpace: FlexibleSpaceBar(
                title: Text('Sliver App Bar'),
                background: Image.network(
                  'https://gunung.id/wp-content/uploads/2018/08/gunung-prau.jpg', // <===   Add your own image to assets or use a .network image instead.
                  fit: BoxFit.cover,
                ),
              ),
            ),
            
            SliverFillRemaining(
              child: SingleChildScrollView(
                child: Column(
                  children: List<int>.generate(50, (index) => index)
                      .map((index) => Container(
                            height: 40,
                            margin: EdgeInsets.symmetric(vertical: 10),
                            color: Colors.grey[300],
                            alignment: Alignment.center,
                            child: Text('Heading $index'),
                          ))
                      .toList(),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Semoga Bermanfaat.

Flutter Developer