Skip to content

Commit fc231c8

Browse files
committed
Null safety and convert to dart template
1 parent cab23e9 commit fc231c8

File tree

11 files changed

+89
-102
lines changed

11 files changed

+89
-102
lines changed

.gitignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Files and directories created by pub
1+
# Files and directories created by pub.
22
.dart_tool/
33
.packages
4-
# Remove the following pattern if you wish to check in your lock file
5-
pubspec.lock
64

7-
# Conventional directory for build outputs
5+
# Conventional directory for build outputs.
86
build/
97

10-
# Directory created by dartdoc
11-
doc/api/
8+
# Omit committing pubspec.lock for library packages; see
9+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
10+
pubspec.lock

CHANGELOG.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
1+
## 0.8.0
2+
3+
- Null safety and convert to dart template
4+
15
## 0.7.2
2-
* Minor Bootstrap fix
6+
7+
- Minor Bootstrap fix
38

49
## 0.7.1
5-
* Fixed Bootstrap issues
10+
11+
- Fixed Bootstrap issues
612

713
## 0.7.0
814

9-
* **New** modal dialog
15+
- **New** modal dialog
1016

1117
## 0.6.2
1218

13-
* Bootstrap 4 support
19+
- Bootstrap 4 support
1420

1521
## 0.6.1
1622

17-
* Apply Bootstrap css only to dialogs
23+
- Apply Bootstrap css only to dialogs
1824

1925
## 0.6.0
2026

21-
* Dart 2 support
27+
- Dart 2 support
2228

2329
## 0.5.0
2430

25-
* Resolved issues with Bootstrap
26-
* Fixed removing dialogs when closed
31+
- Resolved issues with Bootstrap
32+
- Fixed removing dialogs when closed
2733

2834
## 0.4.1
2935

30-
* Fixed enter key bug in prompt
36+
- Fixed enter key bug in prompt
3137

3238
## 0.4.0
3339

34-
* Resolved bugged order using dart:async
35-
* Added onKeyDown listeners for Enter or ESC
40+
- Resolved bugged order using dart:async
41+
- Added onKeyDown listeners for Enter or ESC
3642

3743
## 0.3.0
3844

39-
* Formatted by dartfmt
40-
* Added screenshots to the description
41-
* Added a few additional Bootstrap styles
45+
- Formatted by dartfmt
46+
- Added screenshots to the description
47+
- Added a few additional Bootstrap styles
4248

4349
## 0.2.0
4450

45-
* Reworked to work (but still buggy)
51+
- Reworked to work (but still buggy)
4652

4753
## 0.1.0
4854

49-
* **New** alert dialog
50-
* **New** confirm dialog
51-
* **New** prompt dialog
55+
- **New** alert dialog
56+
- **New** confirm dialog
57+
- **New** prompt dialog

analysis_options.yaml

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,30 @@
1-
# Defines a default set of lint rules enforced for
2-
# projects at Google. For details and rationale,
3-
# see https://github.com/dart-lang/pedantic#enabled-lints.
4-
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
5-
linter:
6-
rules:
7-
- always_declare_return_types
8-
- always_require_non_null_named_parameters
9-
- annotate_overrides
10-
- avoid_empty_else
11-
- avoid_init_to_null
12-
- avoid_null_checks_in_equality_operators
13-
- avoid_relative_lib_imports
14-
- avoid_return_types_on_setters
15-
- avoid_shadowing_type_parameters
16-
- avoid_types_as_parameter_names
17-
- camel_case_extensions
18-
- curly_braces_in_flow_control_structures
19-
- empty_catches
20-
- empty_constructor_bodies
21-
- library_names
22-
- library_prefixes
23-
- no_duplicate_case_values
24-
- null_closures
25-
- prefer_adjacent_string_concatenation
26-
- prefer_collection_literals
27-
- prefer_conditional_assignment
28-
- prefer_contains
29-
- prefer_equal_for_default_values
30-
- prefer_final_fields
31-
- prefer_for_elements_to_map_fromIterable
32-
- prefer_generic_function_type_aliases
33-
- prefer_if_null_operators
34-
- prefer_is_empty
35-
- prefer_is_not_empty
36-
- prefer_iterable_whereType
37-
- prefer_double_quotes
38-
- prefer_spread_collections
39-
- recursive_getters
40-
- slash_for_doc_comments
41-
- type_init_formals
42-
- unnecessary_const
43-
- unnecessary_new
44-
- unnecessary_null_in_if_null_operators
45-
- unnecessary_this
46-
- unrelated_type_equality_checks
47-
- use_function_type_syntax_for_parameters
48-
- use_rethrow_when_possible
49-
- valid_regexps
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

example/index.dart renamed to example/example.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import "dart:html";
22
import "package:dialog/dialog.dart";
33

44
void main() {
5-
querySelector("#alertButton").onClick.listen((_) {
5+
querySelector("#alertButton")!.onClick.listen((_) {
66
alert("Alerted?!");
77
});
8-
querySelector("#confirmButton").onClick.listen((_) async {
8+
querySelector("#confirmButton")!.onClick.listen((_) async {
99
var myConfirm = await confirm("Confirmed?!");
1010
alert(myConfirm.toString());
1111
});
12-
querySelector("#promptButton").onClick.listen((_) async {
12+
querySelector("#promptButton")!.onClick.listen((_) async {
1313
var myPrompt = await prompt("Prompted?!", "Yes!");
1414
alert(myPrompt.toString());
1515
});
16-
querySelector("#modalButton").onClick.listen((_) async {
16+
querySelector("#modalButton")!.onClick.listen((_) async {
1717
var myModal = await modal(
1818
"Surprise", [Text("Boo!")], "Eek!", "Huh?", "Haha!", "Come on!", true);
1919
alert(myModal.toString());

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ <H2>dialog.dart</H2>
6969

7070
Do you need to use them all at once? Try to import dialog.dart file only!
7171

72-
<Script Defer Src="index.dart.js"></Script>
72+
<Script Defer Src="example.dart.js"></Script>
7373
</Body>
7474
</Html>

lib/dialogs/alert.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library dialog.alert;
22

33
import "dart:html";
4-
import "../src/dialog_class.dart";
4+
import "../src/dialog_base.dart";
55

66
void alert([String message = ""]) {
77
Dialog alertDialog = Dialog("Alert", [Text(message)]);

lib/dialogs/confirm.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library dialog.confirm;
22

33
import "dart:async";
44
import "dart:html";
5-
import "../src/dialog_class.dart";
5+
import "../src/dialog_base.dart";
66

77
Future<dynamic> confirm([String message = ""]) async {
88
Completer c = Completer();

lib/dialogs/modal.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ library dialog.modal;
22

33
import "dart:async";
44
import "dart:html";
5-
import "../src/dialog_class.dart";
5+
import "../src/dialog_base.dart";
66

77
Future<dynamic> modal(
88
[String title = "Modal",
99
List<Node> content = const [],
10-
String successText,
11-
String cancelText,
10+
String? successText,
11+
String? cancelText,
1212
dynamic onSuccess,
1313
dynamic onCancel,
14-
bool cancellable,
15-
Element whatToFocus]) async {
14+
bool? cancellable,
15+
Element? whatToFocus]) async {
1616
Completer c = Completer();
1717

1818
Dialog modalDialog =

lib/dialogs/prompt.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library dialog.prompt;
22

33
import "dart:async";
44
import "dart:html";
5-
import "../src/dialog_class.dart";
5+
import "../src/dialog_base.dart";
66

77
Future<dynamic> prompt([String message = "", String value = ""]) async {
88
Completer c = Completer();

lib/src/dialog_class.dart renamed to lib/src/dialog_base.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
library dialog.src.dialog_class;
1+
library dialog.src.dialog_base;
22

33
import "dart:html";
44

55
class Dialog {
66
String title;
77
List<Node> content;
8-
String successText;
9-
String cancelText;
10-
bool cancellable;
8+
String? successText;
9+
String? cancelText;
10+
bool? cancellable;
1111
final DivElement dialog = DivElement();
1212
final DivElement dialogBackdrop = DivElement();
1313
final ButtonElement xButton = ButtonElement();
@@ -18,13 +18,13 @@ class Dialog {
1818
[this.cancellable = false,
1919
this.successText = "OK",
2020
this.cancelText = "Cancel"]) {
21-
if (document.querySelector("body").style.color != "rgb(51, 51, 51)" &&
21+
if (document.querySelector("body")!.style.color != "rgb(51, 51, 51)" &&
2222
querySelectorAll("[href*='packages/dialog/bootstrap.css']").isEmpty) {
2323
LinkElement link = LinkElement()
2424
..href = "packages/dialog/bootstrap.css"
2525
..rel = "stylesheet"
2626
..type = "text/css";
27-
document.querySelector("head").insertAdjacentElement("beforeEnd", link);
27+
document.querySelector("head")!.insertAdjacentElement("beforeEnd", link);
2828
}
2929

3030
dialog
@@ -77,17 +77,17 @@ class Dialog {
7777
}
7878

7979
void showDialog() {
80-
if (document.body.classes.contains("modal-open") == false) {
81-
document.body.children.add(dialog);
80+
if (document.body!.classes.contains("modal-open") == false) {
81+
document.body!.children.add(dialog);
8282
dialogBackdrop.classes.add("show");
8383
dialog.classes.add("show");
84-
document.body.classes.add("modal-open");
84+
document.body!.classes.add("modal-open");
8585
}
8686
}
8787

8888
void closeDialog() {
89-
if (document.body.classes.contains("modal-open") == true) {
90-
document.body
89+
if (document.body!.classes.contains("modal-open") == true) {
90+
document.body!
9191
..children.remove(dialog)
9292
..children.remove(dialogBackdrop)
9393
..classes.remove("modal-open");

0 commit comments

Comments
 (0)