diff --git a/.gitignore b/.gitignore index b2892da..7972500 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,9 @@ res/ android/ lib/selectable_tags_back.dart +lib/generated_plugin_registrant.dart + example/lib/main_back.dart +example/android/local.properties +example/android/app/src/main/java/* +example/ios/Flutter/* diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh old mode 100644 new mode 100755 index 9756862..ed2333f --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -5,6 +5,8 @@ export "FLUTTER_APPLICATION_PATH=D:\Android\Flutter\package\flutter_tags\example export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "OTHER_LDFLAGS=$(inherited) -framework Flutter" +export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" export "DART_OBFUSCATION=false" diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index e04130f..ab73b3a 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -1,3 +1 @@ -import 'package:flutter/material.dart'; - void main() {} diff --git a/lib/src/item_tags.dart b/lib/src/item_tags.dart index 1ce51b2..5ba41fa 100644 --- a/lib/src/item_tags.dart +++ b/lib/src/item_tags.dart @@ -149,19 +149,21 @@ class _ItemTagsState extends State { _dataListInherited = DataListInherited.of(context); // set List length - if (_dataListInherited!.list!.length < _dataListInherited!.itemCount!) + if (_dataListInherited!.itemCount != null && + _dataListInherited!.list!.length < _dataListInherited!.itemCount!) { _dataListInherited!.list!.length = _dataListInherited!.itemCount!; + } if (_dataListInherited!.list!.length > (widget.index + 1) && _dataListInherited!.list!.elementAt(widget.index) != null && - _dataListInherited!.list!.elementAt(widget.index).title != + _dataListInherited!.list!.elementAt(widget.index)!.title != widget.title) { // when an element is removed from the data source _dataListInherited!.list!.removeAt(widget.index); // when all item list changed in data source if (_dataListInherited!.list!.elementAt(widget.index) != null && - _dataListInherited!.list!.elementAt(widget.index).title != + _dataListInherited!.list!.elementAt(widget.index)!.title != widget.title) _dataListInherited!.list! .removeRange(widget.index, _dataListInherited!.list!.length); @@ -415,16 +417,15 @@ class _ItemTagsState extends State { case MainAxisAlignment.spaceBetween: case MainAxisAlignment.start: return TextAlign.start; - break; + case MainAxisAlignment.end: return TextAlign.end; - break; + case MainAxisAlignment.spaceAround: case MainAxisAlignment.spaceEvenly: case MainAxisAlignment.center: return TextAlign.center; } - return null; } ///TextStyle @@ -438,9 +439,9 @@ class _ItemTagsState extends State { void _singleItem(DataListInherited dataSetIn, DataList? dataSet) { dataSetIn.list! .where((tg) => tg != null) - .where((tg) => tg.active) + .where((tg) => tg!.active) .where((tg2) => tg2 != dataSet) - .forEach((tg) => tg.active = false); + .forEach((tg) => tg!.active = false); } } diff --git a/lib/src/suggestions_textfield.dart b/lib/src/suggestions_textfield.dart index 9663a16..58b50ea 100644 --- a/lib/src/suggestions_textfield.dart +++ b/lib/src/suggestions_textfield.dart @@ -14,8 +14,7 @@ typedef OnSubmittedCallback = void Function(String string); class SuggestionsTextField extends StatefulWidget { SuggestionsTextField( {required this.tagsTextField, this.onSubmitted, Key? key}) - : assert(tagsTextField != null), - super(key: key); + : super(key: key); final TagsTextField tagsTextField; final OnSubmittedCallback? onSubmitted; diff --git a/lib/src/tags.dart b/lib/src/tags.dart index 72d7fd4..207bfcb 100644 --- a/lib/src/tags.dart +++ b/lib/src/tags.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_tags/src/suggestions_textfield.dart'; import '../flutter_tags.dart'; import 'util/custom_wrap.dart'; -import 'package:flutter_tags/src/suggestions_textfield.dart'; ///ItemBuilder typedef Widget ItemBuilder(int index); @@ -25,11 +25,6 @@ class Tags extends StatefulWidget { this.textField, Key? key}) : assert(itemCount >= 0), - assert(alignment != null), - assert(runAlignment != null), - assert(direction != null), - assert(verticalDirection != null), - assert(textDirection != null), super(key: key); ///specific number of columns @@ -87,9 +82,9 @@ class TagsState extends State { Orientation _orientation = Orientation.portrait; double _width = 0; - final List _list = []; + final List _list = []; - List get getAllItem => _list.toList(); + List get getAllItem => _list.toList(); //get the current width of the screen void _getWidthContext() { @@ -164,11 +159,11 @@ class TagsState extends State { tagsTextField: widget.textField!, onSubmitted: (String str) { if (!widget.textField!.duplicates) { - final List lst = + final List lst = _list.where((l) => l != null && l.title == str).toList(); if (lst.isNotEmpty) { - lst.forEach((d) => d.showDuplicate = true); + lst.forEach((d) => d!.showDuplicate = true); return; } } @@ -240,7 +235,7 @@ class DataListInherited extends InheritedWidget { required Widget child}) : super(key: key, child: child); - final List? list; + final List? list; final bool? symmetry; final int? itemCount; diff --git a/lib/src/util/custom_wrap.dart b/lib/src/util/custom_wrap.dart index 32b905e..5fd4efd 100644 --- a/lib/src/util/custom_wrap.dart +++ b/lib/src/util/custom_wrap.dart @@ -1,4 +1,5 @@ import 'dart:math' as math; + import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -104,13 +105,7 @@ class CustomRenderWrap extends RenderBox WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start, TextDirection? textDirection, VerticalDirection verticalDirection = VerticalDirection.down, - }) : assert(direction != null), - assert(alignment != null), - assert(spacing != null), - assert(runAlignment != null), - assert(runSpacing != null), - assert(crossAxisAlignment != null), - _column = column, + }) : _column = column, _symmetry = symmetry, _direction = direction, _alignment = alignment, @@ -142,7 +137,6 @@ class CustomRenderWrap extends RenderBox Axis get direction => _direction; Axis _direction; set direction(Axis value) { - assert(value != null); if (_direction == value) return; _direction = value; markNeedsLayout(); @@ -151,7 +145,6 @@ class CustomRenderWrap extends RenderBox WrapAlignment get alignment => _alignment; WrapAlignment _alignment; set alignment(WrapAlignment value) { - assert(value != null); if (_alignment == value) return; _alignment = value; markNeedsLayout(); @@ -160,7 +153,6 @@ class CustomRenderWrap extends RenderBox double get spacing => _spacing; double _spacing; set spacing(double value) { - assert(value != null); if (_spacing == value) return; _spacing = value; markNeedsLayout(); @@ -169,7 +161,6 @@ class CustomRenderWrap extends RenderBox WrapAlignment get runAlignment => _runAlignment; WrapAlignment _runAlignment; set runAlignment(WrapAlignment value) { - assert(value != null); if (_runAlignment == value) return; _runAlignment = value; markNeedsLayout(); @@ -178,7 +169,6 @@ class CustomRenderWrap extends RenderBox double get runSpacing => _runSpacing; double _runSpacing; set runSpacing(double value) { - assert(value != null); if (_runSpacing == value) return; _runSpacing = value; markNeedsLayout(); @@ -187,7 +177,6 @@ class CustomRenderWrap extends RenderBox WrapCrossAlignment get crossAxisAlignment => _crossAxisAlignment; WrapCrossAlignment _crossAxisAlignment; set crossAxisAlignment(WrapCrossAlignment value) { - assert(value != null); if (_crossAxisAlignment == value) return; _crossAxisAlignment = value; markNeedsLayout(); @@ -202,9 +191,10 @@ class CustomRenderWrap extends RenderBox } } - VerticalDirection get verticalDirection => _verticalDirection; - VerticalDirection _verticalDirection; - set verticalDirection(VerticalDirection value) { + VerticalDirection? get verticalDirection => _verticalDirection; + VerticalDirection? _verticalDirection; + + set verticalDirection(VerticalDirection? value) { if (_verticalDirection != value) { _verticalDirection = value; markNeedsLayout(); @@ -212,10 +202,6 @@ class CustomRenderWrap extends RenderBox } bool get _debugHasNecessaryDirections { - assert(direction != null); - assert(alignment != null); - assert(runAlignment != null); - assert(crossAxisAlignment != null); if (firstChild != null && lastChild != firstChild) { // i.e. there's more than one child switch (direction) { @@ -415,7 +401,6 @@ class CustomRenderWrap extends RenderBox case Axis.vertical: return child.size.height; } - return 0.0; } double _getCrossAxisExtent(RenderBox child) { @@ -425,7 +410,6 @@ class CustomRenderWrap extends RenderBox case Axis.vertical: return child.size.width; } - return 0.0; } Offset _getOffset(double mainAxisOffset, double crossAxisOffset) { @@ -435,7 +419,6 @@ class CustomRenderWrap extends RenderBox case Axis.vertical: return Offset(crossAxisOffset, mainAxisOffset); } - return Offset.zero; } double _getChildCrossAxisOffset(bool flipCrossAxis, double runCrossAxisExtent, @@ -449,7 +432,6 @@ class CustomRenderWrap extends RenderBox case WrapCrossAlignment.center: return freeSpace / 2.0; } - return 0.0; } bool _hasVisualOverflow = false; @@ -463,7 +445,7 @@ class CustomRenderWrap extends RenderBox size = constraints.smallest; return; } - BoxConstraints? childConstraints; + BoxConstraints childConstraints; double mainAxisLimit = 0.0; bool flipMainAxis = false; bool flipCrossAxis = false; @@ -481,8 +463,6 @@ class CustomRenderWrap extends RenderBox if (textDirection == TextDirection.rtl) flipCrossAxis = true; break; } - assert(childConstraints != null); - assert(mainAxisLimit != null); final double spacing = this.spacing; final double runSpacing = this.runSpacing; final List<_RunMetrics> runMetrics = <_RunMetrics>[]; diff --git a/pubspec.lock b/pubspec.lock index 01f8162..03307d6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.7.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,55 +92,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.4.3" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.1" sdks: - dart: ">=2.12.0-133.2.beta <3.0.0" + dart: ">=2.14.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8df5f65..5c1ba20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: flutter_tags description: Creating selectable and input tags (TextField) has never been easier. -version: 1.0.0-nullsafety.1 +version: 0.4.10 author: Antonino Di Natale homepage: https://github.com/Dn-a/flutter_tags/tree/null-safety environment: - sdk: '>=2.12.0-133.2.beta <3.0.0' + sdk: ">=2.12.0-133.2.beta <3.0.0" dependencies: flutter: diff --git a/test/flutter_tags_test.dart b/test/flutter_tags_test.dart index ee9468a..ab73b3a 100644 --- a/test/flutter_tags_test.dart +++ b/test/flutter_tags_test.dart @@ -1,3 +1 @@ -import 'package:flutter_test/flutter_test.dart'; - void main() {}