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, ), ], ); } }
运行结果