| 123456789101112131415161718192021222324252627282930313233343536 |
- import 'package:flutter/widgets.dart';
- extension WidgetDesktopX on Widget {
- /// 仅在桌面端添加点击手势光标
- Widget withClickCursor(bool isDesktop) {
- if (isDesktop) {
- return MouseRegion(cursor: SystemMouseCursors.click, child: this);
- }
- return this;
- }
- }
- extension WidgetShadowX on Widget {
- /// 为 Widget 添加自定义阴影
- Widget withShadow({
- Color shadowColor = const Color(0xFF000000),
- double opacity = 0.18,
- double blurRadius = 3.0,
- Offset offset = const Offset(1, 1),
- double borderRadius = 0.0,
- }) {
- return Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(borderRadius),
- boxShadow: [
- BoxShadow(
- color: shadowColor.withOpacity(opacity),
- blurRadius: blurRadius,
- offset: offset,
- ),
- ],
- ),
- child: this,
- );
- }
- }
|