[READ-ONLY] Mirror of https://github.com/probablykasper/notifier. Android app for scheduling notifications
android app flutter notifications
0

Configure Feed

Select the types of activity you want to include in your feed.

Add basic test

Kasper (Jun 3, 2022, 1:02 AM +0200) 4bf0509e 44dc7c4f

+250 -11
+24
.github/workflows/test.yml
··· 1 + name: Test 2 + on: 3 + push: 4 + branches: 5 + - '*' 6 + pull_request: 7 + workflow_dispatch: 8 + 9 + jobs: 10 + test: 11 + runs-on: ubuntu-latest 12 + steps: 13 + - uses: actions/checkout@v2 14 + 15 + - name: Flutter setup 16 + uses: subosito/flutter-action@v1.4.0 17 + with: 18 + flutter-version: '3.0.1' 19 + 20 + - name: flutter analyze 21 + run: flutter analyze --no-fatal-infos 22 + 23 + - name: flutter test 24 + run: flutter test
+21 -11
lib/notification_item.dart
··· 14 14 static const yearly = "yearly"; 15 15 } 16 16 17 + defaultDate() { 18 + var now = DateTime.now(); 19 + return DateTime(now.year, now.month, now.day, now.hour + 2); 20 + } 21 + 17 22 class NotificationItem { 18 23 String title; 19 24 String description; ··· 35 40 required this.originalDate, 36 41 required this.lastScheduledDate, 37 42 }); 43 + NotificationItem.defaultWith({ 44 + this.title = '', 45 + this.description = '', 46 + this.disabled = false, 47 + this.repeat = Repeat.never, 48 + this.repeatEvery = 1, 49 + this.weekdays = const [false, false, false, false, false, false, false], 50 + DateTime? originalDate, 51 + this.lastScheduledDate, 52 + }) : originalDate = originalDate ?? DateTime.now(); 53 + 38 54 factory NotificationItem.getDefault() { 39 - var now = DateTime.now(); 40 - return NotificationItem( 41 - title: '', 42 - description: '', 43 - disabled: false, 44 - repeat: Repeat.never, 45 - repeatEvery: 1, 46 - weekdays: [false, false, false, false, false, false, false], 47 - originalDate: DateTime(now.year, now.month, now.day, now.hour + 2), 48 - lastScheduledDate: null, 49 - ); 55 + return NotificationItem.defaultWith(); 50 56 } 51 57 52 58 DateTime getLatestDate() { ··· 164 170 // never happens 165 171 return null; 166 172 } 173 + } 174 + 175 + DateTime? testGetDirectlyNextDate() { 176 + return _getDirectlyNextDate(lastScheduledDate); 167 177 } 168 178 169 179 /// Get the next date for scheduling a notification.
+189
pubspec.lock
··· 1 1 # Generated by pub 2 2 # See https://dart.dev/tools/pub/glossary#lockfile 3 3 packages: 4 + _fe_analyzer_shared: 5 + dependency: transitive 6 + description: 7 + name: _fe_analyzer_shared 8 + url: "https://pub.dartlang.org" 9 + source: hosted 10 + version: "40.0.0" 11 + analyzer: 12 + dependency: transitive 13 + description: 14 + name: analyzer 15 + url: "https://pub.dartlang.org" 16 + source: hosted 17 + version: "4.1.0" 4 18 android_alarm_manager_plus: 5 19 dependency: "direct main" 6 20 description: ··· 73 87 url: "https://pub.dartlang.org" 74 88 source: hosted 75 89 version: "1.16.0" 90 + convert: 91 + dependency: transitive 92 + description: 93 + name: convert 94 + url: "https://pub.dartlang.org" 95 + source: hosted 96 + version: "3.0.2" 97 + coverage: 98 + dependency: transitive 99 + description: 100 + name: coverage 101 + url: "https://pub.dartlang.org" 102 + source: hosted 103 + version: "1.3.2" 76 104 crypto: 77 105 dependency: transitive 78 106 description: ··· 137 165 description: flutter 138 166 source: sdk 139 167 version: "0.0.0" 168 + frontend_server_client: 169 + dependency: transitive 170 + description: 171 + name: frontend_server_client 172 + url: "https://pub.dartlang.org" 173 + source: hosted 174 + version: "2.1.3" 140 175 get: 141 176 dependency: "direct main" 142 177 description: ··· 144 179 url: "https://pub.dartlang.org" 145 180 source: hosted 146 181 version: "4.6.5" 182 + glob: 183 + dependency: transitive 184 + description: 185 + name: glob 186 + url: "https://pub.dartlang.org" 187 + source: hosted 188 + version: "2.0.2" 189 + http_multi_server: 190 + dependency: transitive 191 + description: 192 + name: http_multi_server 193 + url: "https://pub.dartlang.org" 194 + source: hosted 195 + version: "3.2.0" 196 + http_parser: 197 + dependency: transitive 198 + description: 199 + name: http_parser 200 + url: "https://pub.dartlang.org" 201 + source: hosted 202 + version: "4.0.1" 147 203 image: 148 204 dependency: transitive 149 205 description: ··· 158 214 url: "https://pub.dartlang.org" 159 215 source: hosted 160 216 version: "0.17.0" 217 + io: 218 + dependency: transitive 219 + description: 220 + name: io 221 + url: "https://pub.dartlang.org" 222 + source: hosted 223 + version: "1.0.3" 161 224 js: 162 225 dependency: transitive 163 226 description: ··· 172 235 url: "https://pub.dartlang.org" 173 236 source: hosted 174 237 version: "2.0.0" 238 + logging: 239 + dependency: transitive 240 + description: 241 + name: logging 242 + url: "https://pub.dartlang.org" 243 + source: hosted 244 + version: "1.0.2" 175 245 matcher: 176 246 dependency: transitive 177 247 description: ··· 193 263 url: "https://pub.dartlang.org" 194 264 source: hosted 195 265 version: "1.7.0" 266 + mime: 267 + dependency: transitive 268 + description: 269 + name: mime 270 + url: "https://pub.dartlang.org" 271 + source: hosted 272 + version: "1.0.2" 273 + node_preamble: 274 + dependency: transitive 275 + description: 276 + name: node_preamble 277 + url: "https://pub.dartlang.org" 278 + source: hosted 279 + version: "2.0.1" 280 + package_config: 281 + dependency: transitive 282 + description: 283 + name: package_config 284 + url: "https://pub.dartlang.org" 285 + source: hosted 286 + version: "2.0.2" 196 287 path: 197 288 dependency: transitive 198 289 description: ··· 242 333 url: "https://pub.dartlang.org" 243 334 source: hosted 244 335 version: "2.1.2" 336 + pool: 337 + dependency: transitive 338 + description: 339 + name: pool 340 + url: "https://pub.dartlang.org" 341 + source: hosted 342 + version: "1.5.0" 245 343 process: 246 344 dependency: transitive 247 345 description: ··· 249 347 url: "https://pub.dartlang.org" 250 348 source: hosted 251 349 version: "4.2.4" 350 + pub_semver: 351 + dependency: transitive 352 + description: 353 + name: pub_semver 354 + url: "https://pub.dartlang.org" 355 + source: hosted 356 + version: "2.1.1" 252 357 shared_preferences: 253 358 dependency: "direct main" 254 359 description: ··· 305 410 url: "https://pub.dartlang.org" 306 411 source: hosted 307 412 version: "2.1.1" 413 + shelf: 414 + dependency: transitive 415 + description: 416 + name: shelf 417 + url: "https://pub.dartlang.org" 418 + source: hosted 419 + version: "1.3.0" 420 + shelf_packages_handler: 421 + dependency: transitive 422 + description: 423 + name: shelf_packages_handler 424 + url: "https://pub.dartlang.org" 425 + source: hosted 426 + version: "3.0.0" 427 + shelf_static: 428 + dependency: transitive 429 + description: 430 + name: shelf_static 431 + url: "https://pub.dartlang.org" 432 + source: hosted 433 + version: "1.1.0" 434 + shelf_web_socket: 435 + dependency: transitive 436 + description: 437 + name: shelf_web_socket 438 + url: "https://pub.dartlang.org" 439 + source: hosted 440 + version: "1.0.1" 308 441 sky_engine: 309 442 dependency: transitive 310 443 description: flutter 311 444 source: sdk 312 445 version: "0.0.99" 446 + source_map_stack_trace: 447 + dependency: transitive 448 + description: 449 + name: source_map_stack_trace 450 + url: "https://pub.dartlang.org" 451 + source: hosted 452 + version: "2.1.0" 453 + source_maps: 454 + dependency: transitive 455 + description: 456 + name: source_maps 457 + url: "https://pub.dartlang.org" 458 + source: hosted 459 + version: "0.10.10" 313 460 source_span: 314 461 dependency: transitive 315 462 description: ··· 345 492 url: "https://pub.dartlang.org" 346 493 source: hosted 347 494 version: "1.2.0" 495 + test: 496 + dependency: "direct main" 497 + description: 498 + name: test 499 + url: "https://pub.dartlang.org" 500 + source: hosted 501 + version: "1.21.1" 348 502 test_api: 349 503 dependency: transitive 350 504 description: ··· 352 506 url: "https://pub.dartlang.org" 353 507 source: hosted 354 508 version: "0.4.9" 509 + test_core: 510 + dependency: transitive 511 + description: 512 + name: test_core 513 + url: "https://pub.dartlang.org" 514 + source: hosted 515 + version: "0.4.13" 355 516 typed_data: 356 517 dependency: transitive 357 518 description: ··· 366 527 url: "https://pub.dartlang.org" 367 528 source: hosted 368 529 version: "2.1.2" 530 + vm_service: 531 + dependency: transitive 532 + description: 533 + name: vm_service 534 + url: "https://pub.dartlang.org" 535 + source: hosted 536 + version: "8.3.0" 537 + watcher: 538 + dependency: transitive 539 + description: 540 + name: watcher 541 + url: "https://pub.dartlang.org" 542 + source: hosted 543 + version: "1.0.1" 544 + web_socket_channel: 545 + dependency: transitive 546 + description: 547 + name: web_socket_channel 548 + url: "https://pub.dartlang.org" 549 + source: hosted 550 + version: "2.2.0" 551 + webkit_inspection_protocol: 552 + dependency: transitive 553 + description: 554 + name: webkit_inspection_protocol 555 + url: "https://pub.dartlang.org" 556 + source: hosted 557 + version: "1.1.0" 369 558 win32: 370 559 dependency: transitive 371 560 description:
+1
pubspec.yaml
··· 43 43 url: https://github.com/fluttercommunity/plus_plugins.git 44 44 ref: refs/pull/810/head 45 45 path: packages/android_alarm_manager_plus 46 + test: ^1.21.1 46 47 47 48 dev_dependencies: 48 49 flutter_test:
+15
test/notification_item_test.dart
··· 1 + import 'package:test/test.dart' show test, expect; 2 + import 'package:notifier/notification_item.dart' show NotificationItem, Repeat; 3 + 4 + main() { 5 + test('Weekly schedule next day', () { 6 + var item = NotificationItem.defaultWith( 7 + originalDate: DateTime(2018, 1, 1), 8 + lastScheduledDate: DateTime(2018, 1, 1), 9 + repeat: Repeat.weekly, 10 + repeatEvery: 1, 11 + weekdays: [true, true, true, true, true, true, true], 12 + ); 13 + expect(item.testGetDirectlyNextDate(), DateTime(2018, 1, 2)); 14 + }); 15 + }