Hide Appbar on Scroll Flutter?

后端 未结 4 797
不知归路
不知归路 2020-12-07 17:21

Consider this image. As you can see it has an appbar and the appbar has Tabbed buttons. Am trying to animate the appbar so that it hides on scrollup and leaves only

4条回答
  •  抹茶落季
    2020-12-07 17:38

    I suggest that you have to go through SliverAppBar and SliverList To achieve your layout. Following code may help you to understand that.

    import 'package:flutter/material.dart';
    
    void main() {
      runApp(new MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: 'Flutter Demo',
          home: new MyHomePage(),
          debugShowCheckedModeBanner: false,
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State {
      @override
      Widget build(BuildContext context) {
    
        List buildTextViews(int count) {
          List strings = List();
          for (int i = 0; i < count; i++) {
            strings.add(new Padding(padding: new EdgeInsets.all(16.0),
                child: new Text("Item number " + i.toString(),
                    style: new TextStyle(fontSize: 20.0))));
          }
          return strings;
        }
    
        return Scaffold(
            body: new CustomScrollView(slivers: [
              const SliverAppBar(
                title: const Text('Sliver App Bar'),
              ),
              new SliverList(
                  delegate: new SliverChildListDelegate(buildTextViews(50)))
            ])
        );
      }
    }
    

提交回复
热议问题