From 0f62e499a7e28a1f26669cdbf2582acfbbdcd7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Roumy?= Date: Thu, 1 Apr 2021 09:26:23 +0200 Subject: [PATCH 1/3] support null safety --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 42 ++++++++++++++++++------------------ example/pubspec.yaml | 2 ++ lib/format_markdown.dart | 6 +++--- lib/markdown_text_input.dart | 8 +++---- pubspec.lock | 38 ++++++++++++++++---------------- pubspec.yaml | 4 ++-- 7 files changed, 55 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 860be78..e2d204d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.0.0] - 2021/04/01 + +* Migrate to null-safety. + ## [1.0.2] - 2021/02/11 * Reposition cursor if style applied while no text were selected diff --git a/example/pubspec.lock b/example/pubspec.lock index 1a93713..d76d201 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -14,42 +14,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -70,7 +70,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -101,28 +101,28 @@ packages: path: ".." relative: true source: path - version: "1.0.2" + version: "2.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.10.7 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.10.7" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3e8539b..94c37f0 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,6 +6,8 @@ version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" +publish_to: none + dependencies: flutter: sdk: flutter diff --git a/lib/format_markdown.dart b/lib/format_markdown.dart index ee8e943..95b22ed 100644 --- a/lib/format_markdown.dart +++ b/lib/format_markdown.dart @@ -5,8 +5,8 @@ class FormatMarkdown { /// [titleSize] is used for markdown titles static ResultMarkdown convertToMarkdown(MarkdownType type, String data, int fromIndex, int toIndex, {int titleSize = 1}) { - String changedData; - int replaceCursorIndex; + late String changedData; + int? replaceCursorIndex; switch (type) { case MarkdownType.bold: @@ -52,7 +52,7 @@ class ResultMarkdown { int cursorIndex; /// index at which cursor need to be replaced if no text selected - int replaceCursorIndex; + int? replaceCursorIndex; /// Return [ResultMarkdown] ResultMarkdown(this.data, this.cursorIndex, this.replaceCursorIndex); diff --git a/lib/markdown_text_input.dart b/lib/markdown_text_input.dart index 51049f1..459d277 100644 --- a/lib/markdown_text_input.dart +++ b/lib/markdown_text_input.dart @@ -10,7 +10,7 @@ class MarkdownTextInput extends StatefulWidget { final String initialValue; /// Validator for the TextFormField - final String Function(String value) validators; + final String Function(String? value)? validators; /// String displayed at hintText in TextFormField final String label; @@ -45,7 +45,7 @@ class _MarkdownTextInputState extends State { .copyWith(text: result.data, selection: TextSelection.collapsed(offset: basePosition + result.cursorIndex)); if (noTextSelected) { - _controller.selection = TextSelection.collapsed(offset: _controller.selection.end - result.replaceCursorIndex); + _controller.selection = TextSelection.collapsed(offset: _controller.selection.end - result.replaceCursorIndex!); } } @@ -80,9 +80,9 @@ class _MarkdownTextInputState extends State { maxLines: widget.maxLines, controller: _controller, textCapitalization: TextCapitalization.sentences, - validator: (value) => widget.validators(value), + validator: (value) => widget.validators!(value), cursorColor: Theme.of(context).primaryColor, - textDirection: widget.textDirection ?? TextDirection.ltr, + textDirection: widget.textDirection, decoration: InputDecoration( enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor)), focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor)), diff --git a/pubspec.lock b/pubspec.lock index 5b0798c..13870f6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" effective_dart: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,21 +73,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -99,55 +99,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index df45755..bee7163 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: markdown_editable_textinput description: A TextField Widget that allow you to convert easily what's in the TextField to Markdown. -version: 1.0.2 +version: 2.0.0 homepage: https://github.com/playmoweb/markdown-editable-textinput repository: https://github.com/playmoweb/markdown-editable-textinput environment: - sdk: ">=2.2.2 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: From b03ce3236918f7c9bb316ab5622e713de539c38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Roumy?= Date: Thu, 1 Apr 2021 09:31:07 +0200 Subject: [PATCH 2/3] upgrade dependencies --- example/pubspec.lock | 2 +- pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index d76d201..ff53e31 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -63,7 +63,7 @@ packages: name: effective_dart url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" fake_async: dependency: transitive description: diff --git a/pubspec.lock b/pubspec.lock index 13870f6..6553bca 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,7 +49,7 @@ packages: name: effective_dart url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bee7163..a9b42df 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - effective_dart: ^1.2.1 + effective_dart: ^1.3.1 dev_dependencies: From 7fa94890922383367e2518a50903e57cd703bb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Roumy?= Date: Thu, 1 Apr 2021 10:03:02 +0200 Subject: [PATCH 3/3] fix --- .../project.xcworkspace/contents.xcworkspacedata | 2 +- lib/format_markdown.dart | 4 ++-- lib/markdown_text_input.dart | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/lib/format_markdown.dart b/lib/format_markdown.dart index 95b22ed..394ba2b 100644 --- a/lib/format_markdown.dart +++ b/lib/format_markdown.dart @@ -6,7 +6,7 @@ class FormatMarkdown { static ResultMarkdown convertToMarkdown(MarkdownType type, String data, int fromIndex, int toIndex, {int titleSize = 1}) { late String changedData; - int? replaceCursorIndex; + late int replaceCursorIndex; switch (type) { case MarkdownType.bold: @@ -52,7 +52,7 @@ class ResultMarkdown { int cursorIndex; /// index at which cursor need to be replaced if no text selected - int? replaceCursorIndex; + int replaceCursorIndex; /// Return [ResultMarkdown] ResultMarkdown(this.data, this.cursorIndex, this.replaceCursorIndex); diff --git a/lib/markdown_text_input.dart b/lib/markdown_text_input.dart index 459d277..c256e16 100644 --- a/lib/markdown_text_input.dart +++ b/lib/markdown_text_input.dart @@ -45,7 +45,7 @@ class _MarkdownTextInputState extends State { .copyWith(text: result.data, selection: TextSelection.collapsed(offset: basePosition + result.cursorIndex)); if (noTextSelected) { - _controller.selection = TextSelection.collapsed(offset: _controller.selection.end - result.replaceCursorIndex!); + _controller.selection = TextSelection.collapsed(offset: _controller.selection.end - result.replaceCursorIndex); } }