forked from lxm_flutter/FlutterUnit
初步优化项目结构
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
/// create by 张风捷特烈 on 2020-04-19
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
// {
|
||||
// "widgetId": 81,
|
||||
// "name": 'UnConstrainedBox基本使用',
|
||||
// "priority": 1,
|
||||
// "subtitle":
|
||||
// "【child】 : 孩子组件 【Widget】\n"
|
||||
// "【constrainedAxis】 : 仍受约束的轴*2 【Axis】\n"
|
||||
// "【alignment】 : 对齐方式 【AlignmentGeometry】",
|
||||
// }
|
||||
class CustomUnConstrainedBox extends StatefulWidget {
|
||||
@override
|
||||
_CustomUnConstrainedBoxState createState() => _CustomUnConstrainedBoxState();
|
||||
}
|
||||
|
||||
class _CustomUnConstrainedBoxState extends State<CustomUnConstrainedBox> {
|
||||
var _value = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
spacing: 20,
|
||||
children: <Widget>[_buildUnconstrainedBox(), _buildConstrainedAxis()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUnconstrainedBox() {
|
||||
var child = Container(
|
||||
color: Colors.cyanAccent,
|
||||
width: 60,
|
||||
height: 60,
|
||||
child: Switch(
|
||||
value: _value,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
_value = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Colors.grey.withAlpha(22),
|
||||
width: 150,
|
||||
height: 100,
|
||||
child: _value
|
||||
? UnconstrainedBox(alignment: Alignment.center, child: child)
|
||||
: child,
|
||||
),
|
||||
Text(_value ? "已解除约束" : "子组件受约束")
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildConstrainedAxis() {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Colors.grey.withAlpha(22),
|
||||
width: 150,
|
||||
height: 100,
|
||||
child: UnconstrainedBox(
|
||||
alignment: Alignment.center,
|
||||
constrainedAxis: Axis.vertical,
|
||||
child: Container(
|
||||
color: Colors.cyanAccent,
|
||||
width: 60,
|
||||
height: 60,
|
||||
)),
|
||||
),
|
||||
Text("竖直方向仍约束")
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user