IndexedStack(每日Flutter 小部件)

/**
 *  集成自Stack,用来显示第index个child,
 *  IndexedStack({
    Key key,
    AlignmentGeometry alignment = AlignmentDirectional.topStart,
    TextDirection textDirection,
    StackFit sizing = StackFit.loose,
    this.index = 0,
    List<Widget> children = const <Widget>[],
    })
 */

例:

import 'package:flutter/material.dart';

class IndexedStackWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return IndexedStack(
      alignment: AlignmentDirectional.center,
      textDirection: TextDirection.ltr,
      sizing: StackFit.loose,
      index: 0,
      children: [
        Container(
          width: 100,
          height: 100,
          color: Colors.red,
        ),
        Container(
          width: 80,
          height: 80,
          color: Colors.blue,
        ),
        Container(
          width: 50,
          height: 50,
          color: Colors.green,
        ),
      ],
    );
  }
}

运行结果

 

posted on 2020-03-15 15:59  wjw334  阅读(980)  评论(0编辑  收藏  举报

导航