美文网首页Flutter
Flutter SliverAppBar

Flutter SliverAppBar

作者: 三只仓鼠 | 来源:发表于2020-03-06 11:59 被阅读0次
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: SafeArea(
          child: Scaffold(
        body: Home(),
      )),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverAppBar(
          expandedHeight: 210,
          floating: false,////滑动时是否悬浮
          pinned: true,//固定标题栏
          flexibleSpace: FlexibleSpaceBar(
            title: Text("Demo Title"),
            centerTitle: true,
            background: Image.network(
              "http://pic26.nipic.com/20130122/5056611_171645641000_2.jpg",
              fit: BoxFit.cover,
            ),
          ),
        ),
        SliverFillRemaining(
          child: Container(),
        )
      ],
    );
  }
}

相关文章

网友评论

    本文标题:Flutter SliverAppBar

    本文链接:https://www.haomeiwen.com/subject/fohbrhtx.html