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

icapps / flutter-template / 6027642730

30 Aug 2023 04:38PM UTC coverage: 61.807% (+0.4%) from 61.431%
6027642730

push

github

web-flow
Merge pull request #321 from icapps/#312-add-bottom-nav

#312 add bottom nav

90 of 90 new or added lines in 7 files covered. (100.0%)

1081 of 1749 relevant lines covered (61.81%)

2.5 hits per line

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

93.48
/lib/widget/general/styled/flutter_template_button.dart
1
import 'package:flutter/material.dart';
2
import 'package:flutter_template/styles/theme_data.dart';
3
import 'package:flutter_template/styles/theme_durations.dart';
4
import 'package:flutter_template/widget/provider/data_provider_widget.dart';
5
import 'package:icapps_architecture/icapps_architecture.dart';
6

7
enum ButtonType {
8
  regular,
9
  text,
10
}
11

12
class FlutterTemplateButton extends StatelessWidget {
13
  final String text;
14
  final bool isEnabled;
15
  final bool isExpanded;
16
  final VoidCallback? onClick;
17
  final ButtonType buttonType;
18

19
  const FlutterTemplateButton({
4✔
20
    required this.text,
21
    required this.onClick,
22
    this.isExpanded = true,
23
    this.isEnabled = true,
24
    this.buttonType = ButtonType.regular,
25
    super.key,
26
  });
27

28
  const FlutterTemplateButton.text({
1✔
29
    required this.text,
30
    required this.onClick,
31
    this.isExpanded = false,
32
    this.isEnabled = true,
33
    this.buttonType = ButtonType.text,
34
    super.key,
35
  });
36

37
  TextStyle _enabledTextStyle(FlutterTemplateTheme theme) {
4✔
38
    switch (buttonType) {
4✔
39
      case ButtonType.regular:
4✔
40
        return theme.inverseCoreTextTheme.labelButtonSmall;
8✔
41
      case ButtonType.text:
1✔
42
        return theme.accentTextTheme.labelButtonSmall;
2✔
43
    }
44
  }
45

46
  TextStyle _disabledTextStyle(FlutterTemplateTheme theme) {
3✔
47
    switch (buttonType) {
3✔
48
      case ButtonType.regular:
3✔
49
        return theme.inverseCoreTextTheme.labelButtonSmall;
6✔
50
      case ButtonType.text:
×
51
        return theme.disabledTextTheme.labelButtonSmall;
×
52
    }
53
  }
54

55
  Color? _enabledButtonColor(FlutterTemplateTheme theme) {
4✔
56
    switch (buttonType) {
4✔
57
      case ButtonType.regular:
4✔
58
        return theme.colorsTheme.buttonColor;
8✔
59
      case ButtonType.text:
1✔
60
        return null;
61
    }
62
  }
63

64
  Color? _disabledButtonColor(FlutterTemplateTheme theme) {
3✔
65
    switch (buttonType) {
3✔
66
      case ButtonType.regular:
3✔
67
        return theme.colorsTheme.disabled;
6✔
68
      case ButtonType.text:
×
69
        return null;
70
    }
71
  }
72

73
  @override
4✔
74
  Widget build(BuildContext context) {
75
    return DataProviderWidget(
4✔
76
      childBuilderTheme: (context, theme) {
4✔
77
        final content = Row(
4✔
78
          mainAxisSize: isExpanded ? MainAxisSize.max : MainAxisSize.min,
4✔
79
          mainAxisAlignment: MainAxisAlignment.center,
80
          children: [
4✔
81
            Padding(
4✔
82
              padding: const EdgeInsets.symmetric(
83
                vertical: 16,
84
                horizontal: 24,
85
              ),
86
              child: AnimatedDefaultTextStyle(
4✔
87
                style: isEnabled ? _enabledTextStyle(theme) : _disabledTextStyle(theme),
11✔
88
                duration: ThemeDurations.shortAnimationDuration(),
4✔
89
                child: Text(text),
8✔
90
              ),
91
            ),
92
          ],
93
        );
94
        if (context.isIOSTheme) {
4✔
95
          return TouchFeedBack(
1✔
96
            onClick: isEnabled ? onClick : null,
2✔
97
            child: AnimatedContainer(
1✔
98
              color: isEnabled ? _enabledButtonColor(theme) : _disabledButtonColor(theme),
3✔
99
              duration: ThemeDurations.shortAnimationDuration(),
1✔
100
              child: content,
101
            ),
102
          );
103
        }
104
        return AnimatedContainer(
4✔
105
          color: isEnabled ? _enabledButtonColor(theme) : _disabledButtonColor(theme),
11✔
106
          duration: ThemeDurations.shortAnimationDuration(),
4✔
107
          child: TouchFeedBack(
4✔
108
            onClick: isEnabled ? onClick : null,
8✔
109
            child: content,
110
          ),
111
        );
112
      },
113
    );
114
  }
115
}
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

© 2026 Coveralls, Inc