作者:范婷柏 | 来源:互联网 | 2023-08-06 14:04
***集成自Stack,用来显示第index个child,*IndexedStack({Keykey,AlignmentGeometryalignmentAlignmentDire
/**
* 集成自Stack,用来显示第index个child,
* IndexedStack({
Key key,
AlignmentGeometry alignment = AlignmentDirectional.topStart,
TextDirection textDirection,
StackFit sizing = StackFit.loose,
this.index = 0,
List children = const [],
})
*/
例:
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,
),
],
);
}
}
运行结果