feat: Phase 2 — upgrade deps to null-safe, replace deprecated packages
- pubspec: bump all maintained deps to null-safe latest; flutter pub get resolves
- Remove 12 packages (0-ref or no null-safe): splashscreen, flappy_search_bar,
searchable_dropdown, share, platform_detect, flutter_inappwebview, countdown,
gender_selection, flutter_dash, smooth_star_rating, hovering, ffi
- Add flutter_rating_bar
- Keep discontinued-but-null-safe for now (Phase 5): pull_to_refresh, hive, catcher
- New null-safe custom components (API-compatible, callers change only imports):
utils/countdown.dart, widgets/general/{hover_widget,gender_selection,
smooth_star_rating,search_bar}.dart
- main.dart: drop dead SplashScreen _buildBody + _to field
- 23 consuming files: swap deprecated imports to local components
Null-safety migration + upgraded-API adaptation = Phase 3.
This commit is contained in:
46
lib/widgets/general/hover_widget.dart
Normal file
46
lib/widgets/general/hover_widget.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 自定义实现,替代已停维的 `hovering` 包的 [HoverWidget]。
|
||||
///
|
||||
/// API 兼容:
|
||||
/// ```dart
|
||||
/// HoverWidget(
|
||||
/// child: ...,
|
||||
/// hoverChild: ...,
|
||||
/// onHover: (PointerHoverEvent event) { ... },
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// 鼠标悬停时显示 [hoverChild],否则显示 [child]。
|
||||
class HoverWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Widget? hoverChild;
|
||||
final void Function(PointerHoverEvent)? onHover;
|
||||
|
||||
const HoverWidget({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.hoverChild,
|
||||
this.onHover,
|
||||
});
|
||||
|
||||
@override
|
||||
State<HoverWidget> createState() => _HoverWidgetState();
|
||||
}
|
||||
|
||||
class _HoverWidgetState extends State<HoverWidget> {
|
||||
bool _hovering = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
onHover: widget.onHover,
|
||||
onEnter: (_) => setState(() => _hovering = true),
|
||||
onExit: (_) => setState(() => _hovering = false),
|
||||
child: (_hovering && widget.hoverChild != null)
|
||||
? widget.hoverChild!
|
||||
: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user