Files
FlutterUnit/lib/views/widgets/SingleChildRenderObjectWidget/IgnorePointer/node1_base.dart
2020-05-03 23:05:53 +08:00

63 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020-04-19
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 292,
// "name": 'IgnorePointer基本使用',
// "priority": 1,
// "subtitle":
// "【child】 : 孩子组件 【Widget】\n"
// "【ignoring】 : 是否忽视事件 【bool】\n"
// "如下,Switch选中时ignoring为true按钮事件将被锁定无法点击。",
// }
class CustomIgnorePointer extends StatefulWidget {
@override
_CustomIgnorePointerState createState() => _CustomIgnorePointerState();
}
class _CustomIgnorePointerState extends State<CustomIgnorePointer> {
bool _ignore = false;
@override
Widget build(BuildContext context) {
return Container(
child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: <Widget>[
GestureDetector(
onTap: (){
print('IgnorePointer');
},
child: IgnorePointer(
ignoring: _ignore,
child: _buildButton(),
),
),
_buildSwitch(),
Text(!_ignore ? '允许点击' : '点击已锁定')
],
),
);
}
Widget _buildButton() => RaisedButton(
color: Theme.of(context).primaryColor,
child: Text(
'To About',
style: TextStyle(color: Colors.white),
),
onPressed: () => Navigator.of(context).pushNamed('AboutMePage'));
_buildSwitch() => Switch(
value: _ignore,
onChanged: (v) {
setState(() {
_ignore = v;
});
});
}