• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icapps / flutter-icapps-architecture / 9346758135

03 Jun 2024 08:22AM CUT coverage: 93.711% (-1.4%) from 95.135%
9346758135

push

github

web-flow
Merge pull request #126 from icapps/feature/hover-color

Feature/hover color

38 of 53 new or added lines in 2 files covered. (71.7%)

894 of 954 relevant lines covered (93.71%)

1.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/lib/src/widget/lifecycle/lifecycle.dart
1
import 'package:flutter/material.dart';
2

3
/// Helper widget for reacting to lifecycle events.
4
/// This widget listens to changes in the [AppLifecycleState].
5
class LifecycleWidget extends StatefulWidget {
6
  /// The widget below this widget in the tree.
7
  final Widget child;
8

9
  /// [onResume] is triggered when the app goes to the [AppLifecycleState.resumed] state.
10
  final VoidCallback? onResume;
11

12
  /// [onPause] is triggered when the app goes to the [AppLifecycleState.paused] state.
13
  final VoidCallback? onPause;
14

15
  /// [onDetached] is triggered when the app goes to the [AppLifecycleState.detached] state.
16
  final VoidCallback? onDetached;
17

18
  /// [onInactive] is triggered when the app goes to the [AppLifecycleState.inactive] state.
19
  final VoidCallback? onInactive;
20

21
  /// [onHidden] is triggered when the app goes to the [AppLifecycleState.hidden] state.
22
  final VoidCallback? onHidden;
23

24
  /// Helper widget for reacting to lifecycle events.
25
  /// This widget listens to changes in the [AppLifecycleState].
26
  const LifecycleWidget({
1✔
27
    required this.child,
28
    this.onResume,
29
    this.onPause,
30
    this.onDetached,
31
    this.onInactive,
32
    this.onHidden,
33
  });
34

35
  @override
1✔
36
  _LifecycleWidgetState createState() => _LifecycleWidgetState();
1✔
37
}
38

39
class _LifecycleWidgetState extends State<LifecycleWidget>
40
    with WidgetsBindingObserver {
41
  @override
1✔
42
  void initState() {
43
    super.initState();
1✔
44
    WidgetsBinding.instance.addObserver(this);
2✔
45
  }
46

47
  @override
1✔
48
  Widget build(BuildContext context) => widget.child;
2✔
49

50
  @override
1✔
51
  void dispose() {
52
    WidgetsBinding.instance.removeObserver(this);
2✔
53
    super.dispose();
1✔
54
  }
55

56
  @override
1✔
57
  void didChangeAppLifecycleState(AppLifecycleState state) {
58
    switch (state) {
59
      case AppLifecycleState.resumed:
1✔
60
        widget.onResume?.call();
3✔
61
        break;
62
      case AppLifecycleState.paused:
1✔
63
        widget.onPause?.call();
3✔
64
        break;
65
      case AppLifecycleState.detached:
1✔
66
        widget.onDetached?.call();
3✔
67
        break;
68
      case AppLifecycleState.inactive:
1✔
69
        widget.onInactive?.call();
3✔
70
        break;
71
      case AppLifecycleState.hidden:
×
72
        widget.onHidden?.call();
×
73
        break;
74
    }
75
  }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc