flutter3.0学习笔记

SliverFillViewport

Preview

SliverFillViewport生成的每一个child都占满全屏。使用场景PageView。构造函数

const SliverFillViewport({
    super.key,
    required this.delegate,
    this.viewportFraction = 1.0,//是否占满全屏
    this.padEnds = true,
  })

例子:

import 'package:flutter/material.dart';

class SliverFillViewportPage extends StatelessWidget {
  const SliverFillViewportPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverFillViewport(
            delegate: SliverChildBuilderDelegate((context,index){
              return Container(
                color: Colors.primaries[index % Colors.primaries.length],
              );
            },childCount: 5),
            viewportFraction: 1.0,
          )
        ],
      ),
    );
  }
}

黄橙色娱乐综艺视频背景配图动感个人分享抖音视频.gif