├── .dart_tool ├── package_config.json ├── package_config_subset └── version ├── .idea ├── .gitignore ├── git_toolbox_prj.xml ├── libraries │ └── Dart_Packages.xml ├── misc.xml └── vcs.xml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── lib └── timer_button.dart ├── pubspec.lock ├── pubspec.yaml ├── screenshots └── demo.png └── test └── timer_button_test.dart /.dart_tool/package_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configVersion": 2, 3 | "packages": [ 4 | { 5 | "name": "async", 6 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/async-2.11.0", 7 | "packageUri": "lib/", 8 | "languageVersion": "2.18" 9 | }, 10 | { 11 | "name": "boolean_selector", 12 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1", 13 | "packageUri": "lib/", 14 | "languageVersion": "2.17" 15 | }, 16 | { 17 | "name": "characters", 18 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/characters-1.3.0", 19 | "packageUri": "lib/", 20 | "languageVersion": "2.12" 21 | }, 22 | { 23 | "name": "clock", 24 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/clock-1.1.1", 25 | "packageUri": "lib/", 26 | "languageVersion": "2.12" 27 | }, 28 | { 29 | "name": "collection", 30 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/collection-1.17.2", 31 | "packageUri": "lib/", 32 | "languageVersion": "2.18" 33 | }, 34 | { 35 | "name": "fake_async", 36 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/fake_async-1.3.1", 37 | "packageUri": "lib/", 38 | "languageVersion": "2.12" 39 | }, 40 | { 41 | "name": "flutter", 42 | "rootUri": "file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter", 43 | "packageUri": "lib/", 44 | "languageVersion": "3.0" 45 | }, 46 | { 47 | "name": "flutter_lints", 48 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/flutter_lints-2.0.3", 49 | "packageUri": "lib/", 50 | "languageVersion": "2.19" 51 | }, 52 | { 53 | "name": "flutter_test", 54 | "rootUri": "file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter_test", 55 | "packageUri": "lib/", 56 | "languageVersion": "3.0" 57 | }, 58 | { 59 | "name": "lints", 60 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/lints-2.1.1", 61 | "packageUri": "lib/", 62 | "languageVersion": "3.0" 63 | }, 64 | { 65 | "name": "matcher", 66 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/matcher-0.12.16", 67 | "packageUri": "lib/", 68 | "languageVersion": "2.18" 69 | }, 70 | { 71 | "name": "material_color_utilities", 72 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/material_color_utilities-0.5.0", 73 | "packageUri": "lib/", 74 | "languageVersion": "2.17" 75 | }, 76 | { 77 | "name": "meta", 78 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/meta-1.9.1", 79 | "packageUri": "lib/", 80 | "languageVersion": "2.12" 81 | }, 82 | { 83 | "name": "path", 84 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/path-1.8.3", 85 | "packageUri": "lib/", 86 | "languageVersion": "2.12" 87 | }, 88 | { 89 | "name": "sky_engine", 90 | "rootUri": "file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/bin/cache/pkg/sky_engine", 91 | "packageUri": "lib/", 92 | "languageVersion": "3.0" 93 | }, 94 | { 95 | "name": "source_span", 96 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/source_span-1.10.0", 97 | "packageUri": "lib/", 98 | "languageVersion": "2.18" 99 | }, 100 | { 101 | "name": "stack_trace", 102 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stack_trace-1.11.0", 103 | "packageUri": "lib/", 104 | "languageVersion": "2.18" 105 | }, 106 | { 107 | "name": "stream_channel", 108 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stream_channel-2.1.1", 109 | "packageUri": "lib/", 110 | "languageVersion": "2.14" 111 | }, 112 | { 113 | "name": "string_scanner", 114 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/string_scanner-1.2.0", 115 | "packageUri": "lib/", 116 | "languageVersion": "2.18" 117 | }, 118 | { 119 | "name": "term_glyph", 120 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/term_glyph-1.2.1", 121 | "packageUri": "lib/", 122 | "languageVersion": "2.12" 123 | }, 124 | { 125 | "name": "test_api", 126 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/test_api-0.6.0", 127 | "packageUri": "lib/", 128 | "languageVersion": "2.18" 129 | }, 130 | { 131 | "name": "vector_math", 132 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/vector_math-2.1.4", 133 | "packageUri": "lib/", 134 | "languageVersion": "2.14" 135 | }, 136 | { 137 | "name": "web", 138 | "rootUri": "file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/web-0.1.4-beta", 139 | "packageUri": "lib/", 140 | "languageVersion": "3.1" 141 | }, 142 | { 143 | "name": "timer_button", 144 | "rootUri": "../", 145 | "packageUri": "lib/", 146 | "languageVersion": "3.0" 147 | } 148 | ], 149 | "generated": "2023-10-08T12:32:00.289217Z", 150 | "generator": "pub", 151 | "generatorVersion": "3.1.2" 152 | } 153 | -------------------------------------------------------------------------------- /.dart_tool/package_config_subset: -------------------------------------------------------------------------------- 1 | async 2 | 2.18 3 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/async-2.11.0/ 4 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/async-2.11.0/lib/ 5 | boolean_selector 6 | 2.17 7 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/ 8 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/lib/ 9 | characters 10 | 2.12 11 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/characters-1.3.0/ 12 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/characters-1.3.0/lib/ 13 | clock 14 | 2.12 15 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/clock-1.1.1/ 16 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/clock-1.1.1/lib/ 17 | collection 18 | 2.18 19 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/collection-1.17.2/ 20 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/collection-1.17.2/lib/ 21 | fake_async 22 | 2.12 23 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/fake_async-1.3.1/ 24 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/fake_async-1.3.1/lib/ 25 | flutter_lints 26 | 2.19 27 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/flutter_lints-2.0.3/ 28 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/flutter_lints-2.0.3/lib/ 29 | lints 30 | 3.0 31 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/lints-2.1.1/ 32 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/lints-2.1.1/lib/ 33 | matcher 34 | 2.18 35 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/matcher-0.12.16/ 36 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/matcher-0.12.16/lib/ 37 | material_color_utilities 38 | 2.17 39 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/material_color_utilities-0.5.0/ 40 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/material_color_utilities-0.5.0/lib/ 41 | meta 42 | 2.12 43 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/meta-1.9.1/ 44 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/meta-1.9.1/lib/ 45 | path 46 | 2.12 47 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/path-1.8.3/ 48 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/path-1.8.3/lib/ 49 | source_span 50 | 2.18 51 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/source_span-1.10.0/ 52 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/source_span-1.10.0/lib/ 53 | stack_trace 54 | 2.18 55 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/ 56 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/lib/ 57 | stream_channel 58 | 2.14 59 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/ 60 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/lib/ 61 | string_scanner 62 | 2.18 63 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/ 64 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/lib/ 65 | term_glyph 66 | 2.12 67 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/ 68 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/lib/ 69 | test_api 70 | 2.18 71 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/test_api-0.6.0/ 72 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/test_api-0.6.0/lib/ 73 | vector_math 74 | 2.14 75 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/vector_math-2.1.4/ 76 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/ 77 | web 78 | 3.1 79 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/web-0.1.4-beta/ 80 | file:///Users/ajaykumar/.pub-cache/hosted/pub.dev/web-0.1.4-beta/lib/ 81 | sky_engine 82 | 3.0 83 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/bin/cache/pkg/sky_engine/ 84 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/bin/cache/pkg/sky_engine/lib/ 85 | flutter 86 | 3.0 87 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter/ 88 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter/lib/ 89 | flutter_test 90 | 3.0 91 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter_test/ 92 | file:///Users/ajaykumar/SDK/FVM/versions/3.13.5/packages/flutter_test/lib/ 93 | timer_button 94 | 3.0 95 | file:///Users/ajaykumar/Workspace/NSIO/timer_button/ 96 | file:///Users/ajaykumar/Workspace/NSIO/timer_button/lib/ 97 | 2 98 | -------------------------------------------------------------------------------- /.dart_tool/version: -------------------------------------------------------------------------------- 1 | 3.13.5 -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/git_toolbox_prj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/Dart_Packages.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.1.1] 2 | 3 | - Updated Documentation and Code Refactoring as per the dart analysis 4 | - Updated `ButtonType` enum values to lowerSnakeCase 5 | 6 | ## [2.1.0] 7 | 8 | - Resolved #13, #16 #17 9 | - Code Refactoring and updated dependencies 10 | - Thanks to all the contributors for their valuable contribution 11 | - [Adakar](https://github.com/Adakar) 12 | - [Priyanshu](https://github.com/Priyanshu-Kashyap) 13 | - [AndresCreator](https://github.com/AndresCreator) 14 | - [CPrimbee](https://github.com/CPrimbee) 15 | - [udcode](https://github.com/udcode) 16 | - [chetanxpatil](https://github.com/chetanxpatil) 17 | 18 | ## [2.0.1] 19 | 20 | - Updated Readme.md 21 | 22 | ## [2.0.1] 23 | 24 | - Updated Readme.md 25 | 26 | ## [2.0.0] 27 | 28 | * Migrating to null safety and Added New buttons. Thanks to [Adakar](https://github.com/Adakar) 29 | * Feature Added: "secPostFix" pass it into the 30 | constructor ([#7](https://github.com/ProjectAJ14/timer_button/issues/7)). Thanks 31 | to [evanholt1](https://github.com/evanholt1) 32 | 33 | ## [1.0.2] 34 | 35 | * Feature Added: Reset timer button ([#5](https://github.com/ProjectAJ14/timer_button/issues/5)). 36 | Thanks to [gerald-tetteh](https://github.com/gerald-tetteh) 37 | 38 | ## [1.0.1] 39 | 40 | * Updated package description 41 | 42 | ## [1.0.0] 43 | 44 | * Updated environment >=2.7.0 <3.0.0 45 | 46 | ## [0.0.6] 47 | 48 | * Minor fixes. 49 | 50 | ## [0.0.5] 51 | 52 | * Updated Example and Documents. 53 | 54 | ## [0.0.4] 55 | 56 | * Minor fixes. 57 | 58 | ## [0.0.3] 59 | 60 | * Updated Example and Documents. 61 | 62 | ## [0.0.2] 63 | 64 | * Added Example 65 | 66 | ## [0.0.1] 67 | 68 | * Initial. 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 Nonstop io Technologies Pvt Ltd 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hi everyone! 👋 2 | 3 | This package has been moved to a new location as part of the Flutter Forge project. You can now find it here: 4 | 👉 https://github.com/nonstopio/flutter_forge/tree/main/packages/timer_button 5 | 6 | Please update your dependencies and links accordingly. If you have any questions or issues, feel free to reach out at the new repository. 7 | 8 | Thank you for your understanding and continued support! 🚀 9 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | #All platforms 47 | android/ 48 | ios/ 49 | linux/ 50 | macos/ 51 | web/ 52 | windows/ -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "12fccda598477eddd19f93040a1dba24f915b9be" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 17 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 18 | - platform: android 19 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 20 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 21 | - platform: ios 22 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 23 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 24 | - platform: linux 25 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 26 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 27 | - platform: macos 28 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 29 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 30 | - platform: web 31 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 32 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 33 | - platform: windows 34 | create_revision: 12fccda598477eddd19f93040a1dba24f915b9be 35 | base_revision: 12fccda598477eddd19f93040a1dba24f915b9be 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # An example for Timer Button 2 | 3 | Run `flutter create .` to generate the platform project files in the `example/` directory so you can run and test the example app. -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:timer_button/timer_button.dart'; 5 | 6 | void main() => runApp(const MyApp()); 7 | 8 | class MyApp extends StatelessWidget { 9 | const MyApp({Key? key}) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return MaterialApp( 14 | title: 'Timer Button Demo', 15 | theme: ThemeData( 16 | primarySwatch: Colors.blue, 17 | ), 18 | home: const MyHomePage(), 19 | debugShowCheckedModeBanner: false, 20 | ); 21 | } 22 | } 23 | 24 | class MyHomePage extends StatefulWidget { 25 | const MyHomePage({Key? key}) : super(key: key); 26 | 27 | @override 28 | MyHomePageState createState() { 29 | return MyHomePageState(); 30 | } 31 | } 32 | 33 | class MyHomePageState extends State with TickerProviderStateMixin { 34 | @override 35 | Widget build(BuildContext context) { 36 | return Scaffold( 37 | appBar: AppBar( 38 | title: const Text('Timer Button Demo'), 39 | ), 40 | body: Material( 41 | child: Center( 42 | child: Padding( 43 | padding: const EdgeInsets.all(8.0), 44 | child: Column( 45 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 46 | children: [ 47 | TimerButton( 48 | label: "Try Again", 49 | timeOutInSeconds: 5, 50 | onPressed: () { 51 | log("Time for some action!"); 52 | }, 53 | ), 54 | TimerButton( 55 | label: "Outlined: Try Again", 56 | timeOutInSeconds: 5, 57 | onPressed: () {}, 58 | buttonType: ButtonType.outlinedButton, 59 | disabledColor: Colors.deepOrange, 60 | color: Colors.green, 61 | activeTextStyle: const TextStyle(color: Colors.yellow), 62 | disabledTextStyle: const TextStyle(color: Colors.pink), 63 | ), 64 | TimerButton( 65 | label: "Text: Try Again", 66 | timeOutInSeconds: -5, 67 | onPressed: () { 68 | log("Time for some action!"); 69 | }, 70 | timeUpFlag: true, 71 | buttonType: ButtonType.textButton, 72 | disabledColor: Colors.deepOrange, 73 | color: Colors.green, 74 | ), 75 | TimerButton.builder( 76 | builder: (context, timeLeft) { 77 | return Text( 78 | "Custom: $timeLeft", 79 | style: const TextStyle(color: Colors.red), 80 | ); 81 | }, 82 | onPressed: () { 83 | log("Time for some action!"); 84 | }, 85 | timeOutInSeconds: 5, 86 | ), 87 | ], 88 | ), 89 | ), 90 | ), 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.17.2" 44 | cupertino_icons: 45 | dependency: "direct main" 46 | description: 47 | name: cupertino_icons 48 | sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.0.6" 52 | fake_async: 53 | dependency: transitive 54 | description: 55 | name: fake_async 56 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "1.3.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_lints: 66 | dependency: "direct dev" 67 | description: 68 | name: flutter_lints 69 | sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 70 | url: "https://pub.dev" 71 | source: hosted 72 | version: "2.0.3" 73 | flutter_test: 74 | dependency: "direct dev" 75 | description: flutter 76 | source: sdk 77 | version: "0.0.0" 78 | lints: 79 | dependency: transitive 80 | description: 81 | name: lints 82 | sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" 83 | url: "https://pub.dev" 84 | source: hosted 85 | version: "2.1.1" 86 | matcher: 87 | dependency: transitive 88 | description: 89 | name: matcher 90 | sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "0.12.16" 94 | material_color_utilities: 95 | dependency: transitive 96 | description: 97 | name: material_color_utilities 98 | sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "0.5.0" 102 | meta: 103 | dependency: transitive 104 | description: 105 | name: meta 106 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "1.9.1" 110 | path: 111 | dependency: transitive 112 | description: 113 | name: path 114 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 115 | url: "https://pub.dev" 116 | source: hosted 117 | version: "1.8.3" 118 | sky_engine: 119 | dependency: transitive 120 | description: flutter 121 | source: sdk 122 | version: "0.0.99" 123 | source_span: 124 | dependency: transitive 125 | description: 126 | name: source_span 127 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "1.10.0" 131 | stack_trace: 132 | dependency: transitive 133 | description: 134 | name: stack_trace 135 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "1.11.0" 139 | stream_channel: 140 | dependency: transitive 141 | description: 142 | name: stream_channel 143 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "2.1.1" 147 | string_scanner: 148 | dependency: transitive 149 | description: 150 | name: string_scanner 151 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "1.2.0" 155 | term_glyph: 156 | dependency: transitive 157 | description: 158 | name: term_glyph 159 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.2.1" 163 | test_api: 164 | dependency: transitive 165 | description: 166 | name: test_api 167 | sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "0.6.0" 171 | timer_button: 172 | dependency: "direct main" 173 | description: 174 | path: ".." 175 | relative: true 176 | source: path 177 | version: "2.1.0" 178 | vector_math: 179 | dependency: transitive 180 | description: 181 | name: vector_math 182 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 183 | url: "https://pub.dev" 184 | source: hosted 185 | version: "2.1.4" 186 | web: 187 | dependency: transitive 188 | description: 189 | name: web 190 | sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 191 | url: "https://pub.dev" 192 | source: hosted 193 | version: "0.1.4-beta" 194 | sdks: 195 | dart: ">=3.1.2 <4.0.0" 196 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: '>=3.1.2 <4.0.0' 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | 35 | # The following adds the Cupertino Icons font to your application. 36 | # Use with the CupertinoIcons class for iOS style icons. 37 | cupertino_icons: ^1.0.2 38 | timer_button: 39 | path: ../ 40 | 41 | dev_dependencies: 42 | flutter_test: 43 | sdk: flutter 44 | 45 | # The "flutter_lints" package below contains a set of recommended lints to 46 | # encourage good coding practices. The lint set provided by the package is 47 | # activated in the `analysis_options.yaml` file located at the root of your 48 | # package. See that file for information about deactivating specific lint 49 | # rules and activating additional ones. 50 | flutter_lints: ^2.0.0 51 | 52 | # For information on the generic Dart part of this file, see the 53 | # following page: https://dart.dev/tools/pub/pubspec 54 | 55 | # The following section is specific to Flutter packages. 56 | flutter: 57 | 58 | # The following line ensures that the Material Icons font is 59 | # included with your application, so that you can use the icons in 60 | # the material Icons class. 61 | uses-material-design: true 62 | 63 | # To add assets to your application, add an assets section, like this: 64 | # assets: 65 | # - images/a_dot_burr.jpeg 66 | # - images/a_dot_ham.jpeg 67 | 68 | # An image asset can refer to one or more resolution-specific "variants", see 69 | # https://flutter.dev/assets-and-images/#resolution-aware 70 | 71 | # For details regarding adding assets from package dependencies, see 72 | # https://flutter.dev/assets-and-images/#from-packages 73 | 74 | # To add custom fonts to your application, add a fonts section here, 75 | # in this "flutter" section. Each entry in this list should have a 76 | # "family" key with the font family name, and a "fonts" key with a 77 | # list giving the asset and other descriptors for the font. For 78 | # example: 79 | # fonts: 80 | # - family: Schyler 81 | # fonts: 82 | # - asset: fonts/Schyler-Regular.ttf 83 | # - asset: fonts/Schyler-Italic.ttf 84 | # style: italic 85 | # - family: Trajan Pro 86 | # fonts: 87 | # - asset: fonts/TrajanPro.ttf 88 | # - asset: fonts/TrajanPro_Bold.ttf 89 | # weight: 700 90 | # 91 | # For details regarding fonts from package dependencies, 92 | # see https://flutter.dev/custom-fonts/#from-packages 93 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /lib/timer_button.dart: -------------------------------------------------------------------------------- 1 | library timer_button; 2 | 3 | import 'dart:async'; 4 | 5 | import 'package:flutter/material.dart'; 6 | 7 | /// Type definition for TimerButton builder. 8 | /// 9 | typedef TimerButtonBuilder = Widget Function(BuildContext context, int seconds); 10 | 11 | enum ButtonType { 12 | elevatedButton, 13 | textButton, 14 | outlinedButton, 15 | custom, 16 | } 17 | 18 | const int aSec = 1; 19 | 20 | const String _secPostFix = 's'; 21 | const String labelSplitter = " | "; 22 | 23 | /// A button that starts a timer and disables itself until the timer is done. 24 | 25 | class TimerButton extends StatefulWidget { 26 | /// Create a TimerButton button. 27 | /// 28 | /// The [label], [onPressed], and [timeOutInSeconds] 29 | /// arguments must not be null. 30 | 31 | ///label 32 | final String label; 33 | 34 | ///secPostFix 35 | final String secPostFix; 36 | 37 | ///[timeOutInSeconds] after which the button is enabled 38 | final int timeOutInSeconds; 39 | 40 | ///[onPressed] Called when the button is tapped or otherwise activated. 41 | final VoidCallback onPressed; 42 | 43 | /// Defines the button's base colors 44 | final Color color; 45 | 46 | /// The color to use for this button's background/border when the button is disabled. 47 | final Color disabledColor; 48 | 49 | /// activeTextStyle 50 | final TextStyle? activeTextStyle; 51 | 52 | ///disabledTextStyle 53 | final TextStyle disabledTextStyle; 54 | 55 | ///buttonType 56 | final ButtonType buttonType; 57 | 58 | ///If resetTimerOnPressed is true reset the 59 | ///timer when the button is pressed : default to true 60 | final bool resetTimerOnPressed; 61 | 62 | /// 63 | final bool timeUpFlag; 64 | 65 | final TimerButtonBuilder? builder; 66 | 67 | const TimerButton({ 68 | Key? key, 69 | required this.label, 70 | required this.onPressed, 71 | required this.timeOutInSeconds, 72 | this.secPostFix = _secPostFix, 73 | this.color = Colors.blue, 74 | this.resetTimerOnPressed = true, 75 | this.timeUpFlag = false, 76 | this.disabledColor = Colors.grey, 77 | this.buttonType = ButtonType.elevatedButton, 78 | this.activeTextStyle, 79 | this.disabledTextStyle = const TextStyle(color: Colors.black45), 80 | }) : builder = null, 81 | super(key: key); 82 | 83 | /// Builder factory for creating a themed [TimerButton]. 84 | /// 85 | const TimerButton.builder({ 86 | Key? key, 87 | required this.builder, 88 | required this.onPressed, 89 | required this.timeOutInSeconds, 90 | this.resetTimerOnPressed = true, 91 | this.timeUpFlag = false, 92 | }) : buttonType = ButtonType.custom, 93 | activeTextStyle = null, 94 | disabledColor = Colors.grey, 95 | color = Colors.blue, 96 | label = '', 97 | secPostFix = _secPostFix, 98 | disabledTextStyle = const TextStyle(color: Colors.black45), 99 | super(key: key); 100 | 101 | @override 102 | State createState() => _TimerButtonState(); 103 | } 104 | 105 | class _TimerButtonState extends State { 106 | bool _timeUpFlag = false; 107 | int _timeCounter = 0; 108 | late Timer _timer; 109 | 110 | String get _timerText => '$_timeCounter${widget.secPostFix}'; 111 | 112 | @override 113 | void initState() { 114 | super.initState(); 115 | _timeCounter = widget.timeOutInSeconds; 116 | _timeUpFlag = widget.timeUpFlag; 117 | WidgetsBinding.instance.addPostFrameCallback((_) { 118 | _updateTime(); 119 | }); 120 | } 121 | 122 | @override 123 | void dispose() { 124 | _timer.cancel(); 125 | super.dispose(); 126 | } 127 | 128 | void _updateState() { 129 | if (mounted) { 130 | setState(() {}); 131 | } 132 | } 133 | 134 | void _updateTime() { 135 | if (_timeUpFlag) { 136 | return; 137 | } 138 | _timer = Timer(const Duration(seconds: aSec), () async { 139 | if (!mounted) return; 140 | _timeCounter--; 141 | _updateState(); 142 | if (_timeCounter >= 0) { 143 | _updateTime(); 144 | } else { 145 | _timeUpFlag = true; 146 | } 147 | }); 148 | } 149 | 150 | void _onPressed() { 151 | _timeUpFlag = false; 152 | _timeCounter = widget.timeOutInSeconds; 153 | _updateState(); 154 | widget.onPressed(); 155 | // reset the timer when the button is pressed 156 | if (widget.resetTimerOnPressed) { 157 | _updateTime(); 158 | } 159 | } 160 | 161 | @override 162 | Widget build(BuildContext context) { 163 | if (widget.builder != null) { 164 | return GestureDetector( 165 | onTap: _timeUpFlag ? _onPressed : null, 166 | child: widget.builder!( 167 | context, 168 | _timeCounter, 169 | ), 170 | ); 171 | } 172 | final color = _timeUpFlag ? widget.color : widget.disabledColor; 173 | final child = TimerButtonChild( 174 | timeUpFlag: _timeUpFlag, 175 | label: widget.label, 176 | timerText: _timerText, 177 | activeTextStyle: widget.activeTextStyle, 178 | disabledTextStyle: widget.disabledTextStyle, 179 | color: color, 180 | buttonType: widget.buttonType, 181 | ); 182 | switch (widget.buttonType) { 183 | case ButtonType.elevatedButton: 184 | return ElevatedButton( 185 | onPressed: _timeUpFlag ? _onPressed : null, 186 | style: ElevatedButton.styleFrom( 187 | foregroundColor: color, 188 | ), 189 | child: child, 190 | ); 191 | case ButtonType.textButton: 192 | return TextButton( 193 | onPressed: _timeUpFlag ? _onPressed : null, 194 | style: TextButton.styleFrom( 195 | backgroundColor: color, 196 | ), 197 | child: child, 198 | ); 199 | case ButtonType.outlinedButton: 200 | return OutlinedButton( 201 | onPressed: _timeUpFlag ? _onPressed : null, 202 | style: OutlinedButton.styleFrom( 203 | side: BorderSide( 204 | color: color, 205 | ), 206 | ), 207 | child: child, 208 | ); 209 | default: 210 | return Container(); 211 | } 212 | } 213 | } 214 | 215 | class TimerButtonChild extends StatelessWidget { 216 | final bool timeUpFlag; 217 | final String label; 218 | final String timerText; 219 | final TextStyle? activeTextStyle; 220 | final TextStyle disabledTextStyle; 221 | final Color color; 222 | final ButtonType buttonType; 223 | 224 | const TimerButtonChild({ 225 | Key? key, 226 | required this.timeUpFlag, 227 | required this.label, 228 | required this.timerText, 229 | this.activeTextStyle, 230 | required this.disabledTextStyle, 231 | required this.color, 232 | required this.buttonType, 233 | }) : super(key: key); 234 | 235 | @override 236 | Widget build(BuildContext context) { 237 | final textStyle = timeUpFlag 238 | ? activeTextStyle ?? 239 | (buttonType == ButtonType.outlinedButton 240 | ? TextStyle(color: color) 241 | : const TextStyle(color: Colors.white)) 242 | : disabledTextStyle; 243 | final text = timeUpFlag ? label : '$label$labelSplitter$timerText'; 244 | 245 | return Text( 246 | text, 247 | style: textStyle, 248 | ); 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.17.2" 44 | fake_async: 45 | dependency: transitive 46 | description: 47 | name: fake_async 48 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.3.1" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_lints: 58 | dependency: "direct dev" 59 | description: 60 | name: flutter_lints 61 | sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 62 | url: "https://pub.dev" 63 | source: hosted 64 | version: "2.0.3" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | lints: 71 | dependency: transitive 72 | description: 73 | name: lints 74 | sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" 75 | url: "https://pub.dev" 76 | source: hosted 77 | version: "2.1.1" 78 | matcher: 79 | dependency: transitive 80 | description: 81 | name: matcher 82 | sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" 83 | url: "https://pub.dev" 84 | source: hosted 85 | version: "0.12.16" 86 | material_color_utilities: 87 | dependency: transitive 88 | description: 89 | name: material_color_utilities 90 | sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "0.5.0" 94 | meta: 95 | dependency: transitive 96 | description: 97 | name: meta 98 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "1.9.1" 102 | path: 103 | dependency: transitive 104 | description: 105 | name: path 106 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "1.8.3" 110 | sky_engine: 111 | dependency: transitive 112 | description: flutter 113 | source: sdk 114 | version: "0.0.99" 115 | source_span: 116 | dependency: transitive 117 | description: 118 | name: source_span 119 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 120 | url: "https://pub.dev" 121 | source: hosted 122 | version: "1.10.0" 123 | stack_trace: 124 | dependency: transitive 125 | description: 126 | name: stack_trace 127 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "1.11.0" 131 | stream_channel: 132 | dependency: transitive 133 | description: 134 | name: stream_channel 135 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "2.1.1" 139 | string_scanner: 140 | dependency: transitive 141 | description: 142 | name: string_scanner 143 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "1.2.0" 147 | term_glyph: 148 | dependency: transitive 149 | description: 150 | name: term_glyph 151 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "1.2.1" 155 | test_api: 156 | dependency: transitive 157 | description: 158 | name: test_api 159 | sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "0.6.0" 163 | vector_math: 164 | dependency: transitive 165 | description: 166 | name: vector_math 167 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "2.1.4" 171 | web: 172 | dependency: transitive 173 | description: 174 | name: web 175 | sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 176 | url: "https://pub.dev" 177 | source: hosted 178 | version: "0.1.4-beta" 179 | sdks: 180 | dart: ">=3.1.0-185.0.dev <4.0.0" 181 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: timer_button 2 | description: Timer Button is a Flutter package that offers a customizable button widget capable of activation after a designated time interval. 3 | version: 2.1.1 4 | homepage: https://github.com/ProjectAJ14/timer_button 5 | documentation: https://github.com/ProjectAJ14/timer_button 6 | repository: https://github.com/ProjectAJ14/timer_button 7 | issue_tracker: https://github.com/ProjectAJ14/timer_button/issues 8 | 9 | environment: 10 | sdk: '>=3.0.0 <4.0.0' 11 | 12 | dependencies: 13 | flutter: 14 | sdk: flutter 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | flutter_lints: ^2.0.3 20 | flutter: 21 | 22 | screenshots: 23 | - description: Demo Button. 24 | path: screenshots/demo.png -------------------------------------------------------------------------------- /screenshots/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectAJ14/timer_button/0f311fc99a617c3eeee5f85146564e008f5c16b9/screenshots/demo.png -------------------------------------------------------------------------------- /test/timer_button_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:timer_button/timer_button.dart'; 4 | 5 | void main() { 6 | group('TimerButton', () { 7 | testWidgets('should enable button when timer is done', (tester) async { 8 | await tester.pumpWidget( 9 | MaterialApp( 10 | home: Scaffold( 11 | body: TimerButton( 12 | label: 'Start', 13 | onPressed: () {}, 14 | timeOutInSeconds: 1, 15 | ), 16 | ), 17 | ), 18 | ); 19 | 20 | await tester.pumpAndSettle(const Duration(seconds: 1)); 21 | 22 | expect(tester.widget(find.byType(ElevatedButton)).enabled, isTrue); 23 | }); 24 | }); 25 | } 26 | //TODO(Ajay) : Add more tests --------------------------------------------------------------------------------