Skip to content

Commit

Permalink
Merge pull request #27 from panuavakul/develop
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
panuavakul authored Mar 7, 2021
2 parents 11dde00 + ee44824 commit 5a22751
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 94 deletions.
4 changes: 2 additions & 2 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutterSdkVersion": "beta"
}
"flutterSdkVersion": "stable"
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.1.0] - 2021/03/04.

## Breaking changes!

- Update package for sound null safety
- [PR](https://github.com/panuavakul/material_tag_editor/pull/23)
- Update example for sound null safety
- [PR](https://github.com/panuavakul/material_tag_editor/pull/23)

Feature

- Expose TextEditingController for text manipulation and getting value
- [PR](https://github.com/panuavakul/material_tag_editor/pull/24)

## [0.0.6] - 2020/11/17.

### Breaking Changes!
Expand Down
53 changes: 39 additions & 14 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,44 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, this.title}) : super(key: key);

final String title;
final String? title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
List<String> values = [];
List<String> _values = [];
final FocusNode _focusNode = FocusNode();
final TextEditingController _textEditingController = TextEditingController();

onDelete(index) {
_onDelete(index) {
setState(() {
values.removeAt(index);
_values.removeAt(index);
});
}

/// This is just an example for using `TextEditingController` to manipulate
/// the the `TextField` just like a normal `TextField`.
_onPressedModifyTextField() {
final text = 'Test';
_textEditingController.text = text;
_textEditingController.value = _textEditingController.value.copyWith(
text: text,
selection: TextSelection(
baseOffset: text.length,
extentOffset: text.length,
),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
title: Text(widget.title ?? ''),
),
body: Center(
child: Padding(
Expand All @@ -49,15 +64,17 @@ class _MyHomePageState extends State<MyHomePage> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TagEditor(
length: values.length,
length: _values.length,
controller: _textEditingController,
focusNode: _focusNode,
delimiters: [',', ' '],
hasAddButton: true,
resetTextOnSubmitted: true,
// This is set to grey just to illustrate the `textStyle` prop
textStyle: TextStyle(color: Colors.grey),
onSubmitted: (outstandingValue) {
setState(() {
values.add(outstandingValue);
_values.add(outstandingValue);
});
},
inputDecoration: const InputDecoration(
Expand All @@ -66,15 +83,23 @@ class _MyHomePageState extends State<MyHomePage> {
),
onTagChanged: (newValue) {
setState(() {
values.add(newValue);
_values.add(newValue);
});
},
tagBuilder: (context, index) => _Chip(
index: index,
label: values[index],
onDeleted: onDelete,
label: _values[index],
onDeleted: _onDelete,
),
),
Divider(),
// This is just a button to illustrate how to use
// TextEditingController to set the value
// or do whatever you want with it
ElevatedButton(
onPressed: _onPressedModifyTextField,
child: Text('Use Controlelr to Set Value'),
),
],
),
),
Expand All @@ -85,9 +110,9 @@ class _MyHomePageState extends State<MyHomePage> {

class _Chip extends StatelessWidget {
const _Chip({
@required this.label,
@required this.onDeleted,
@required this.index,
required this.label,
required this.onDeleted,
required this.index,
});

final String label;
Expand Down
42 changes: 21 additions & 21 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,56 @@ 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:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "1.0.2"
fake_async:
dependency: transitive
description:
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
Expand All @@ -73,28 +73,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
material_tag_editor:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.0.6"
version: "0.1.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.4"
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
Expand All @@ -106,55 +106,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.2"
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-213.1.beta"
dart: ">=2.12.0 <3.0.0"
5 changes: 3 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: example
description: A new Flutter project.
publish_to: "none"

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
Expand All @@ -14,15 +15,15 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
cupertino_icons: ^1.0.2
material_tag_editor:
path: ../

Expand Down
Loading

0 comments on commit 5a22751

Please sign in to comment.