Answers for "scrollable appbar flutter"

1

flutter scroll appbar

class _SomePageState extends State<SomePage> with SingleTickerProviderStateMixin {
  late final TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              title: Text('Weight Tracker'),
              pinned: true,
              floating: true,
              forceElevated: innerBoxIsScrolled,
              bottom: TabBar(
                tabs: <Tab>[
                  Tab(text: 'STATISTICS'),
                  Tab(text: 'HISTORY'),
                ],
                controller: _tabController,
              ),
            ),
          ];
        },
        body: TabBarView(
          controller: _tabController,
          children: <Widget>[
            StatisticsPage(),
            HistoryPage(),
          ],
        ),
      ),
    );
  }
}
Posted by: Guest on August-10-2021
1

how to make a shrinkable action bar in fluttur

Scaffold(
	body: CustomScrollView(
    	slivers: <Widget>[
        	SliverAppBar(
            	expandedHeight : 200.0,
            	floating : false,
            	pinned : true,
            	flexibleSpace : FlexibleSpaceBar(
            	//This exactly likeyour AppBar
            		title: "foo",
                	background: "Whatever you want",
            	),
           	),
            SliverFillRemaining(
            	child: //This is exactly like the body which we have for scaffold
                Center(),
            ),
            
        ],
    ),
)
Posted by: Guest on June-05-2020

Browse Popular Code Answers by Language