forked from artflutter/reactive_forms_widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89ae398
commit 0a89b48
Showing
16 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
.buildlog/ | ||
.history | ||
.svn/ | ||
packages/.mason | ||
|
||
# IntelliJ related | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
If you want to contribute it's now easier than ever. | ||
You can use `mason` to create template for a new widget binding. | ||
|
||
1. Install mason | ||
```shell | ||
# 🎯 Activate from https://pub.dev | ||
dart pub global activate mason_cli | ||
``` | ||
|
||
2. Chose the package you want to add on https://pub.dev | ||
3. Generate a template project in `packages` folder | ||
|
||
- move to `packages` folder | ||
```shell | ||
cd packages | ||
``` | ||
|
||
- to get all bricks registered in mason.yaml run: | ||
```shell | ||
mason get | ||
``` | ||
|
||
- generate template | ||
```shell | ||
mason make reactive_forms_widget_package | ||
``` | ||
|
||
- switch to the project folder | ||
```shell | ||
cd reactive_[your_package_name] | ||
``` | ||
|
||
- generate flutter related stuff | ||
```shell | ||
flutter create . | ||
``` | ||
|
||
- generate flutter related stuff in `example` folder | ||
```shell | ||
cd example && flutter create . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 0.1.0+1 | ||
|
||
- TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# reactive_forms_widget | ||
|
||
[](https://github.com/felangel/mason) | ||
|
||
A new brick created with the Mason CLI. | ||
|
||
_Generated by [mason][1] 🧱_ | ||
|
||
## Getting Started 🚀 | ||
|
||
This is a starting point for a new brick. | ||
A few resources to get you started if this is your first brick template: | ||
|
||
- [Official Mason Documentation][2] | ||
- [Code generation with Mason Blog][3] | ||
- [Very Good Livestream: Felix Angelov Demos Mason][4] | ||
|
||
[1]: https://github.com/felangel/mason | ||
[2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme | ||
[3]: https://verygood.ventures/blog/code-generation-with-mason | ||
[4]: https://youtu.be/G4PTjA6tpTU |
2 changes: 2 additions & 0 deletions
2
...get_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## 0.0.1 | ||
* initial release |
5 changes: 5 additions & 0 deletions
5
...widget_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# reactive_{{originalPackageName.snakeCase()}} | ||
|
||
Wrapper around [{{originalPackageName.snakeCase()}}](https://pub.dev/packages/{{originalPackageName.snakeCase()}}) to use with [`reactive_forms`](https://pub.dev/packages/reactive_forms) | ||
|
||
Docs in progress. See [`example`](https://github.com/artflutter/reactive_forms_widgets/tree/master/packages/reactive_{{originalPackageName.snakeCase()}}/example) folder for sample. |
6 changes: 6 additions & 0 deletions
6
...dget_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/analysis_options.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
analyzer: | ||
strong-mode: | ||
implicit-casts: false | ||
implicit-dynamic: false |
49 changes: 49 additions & 0 deletions
49
...dget_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/example/lib/main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:reactive_{{originalPackageName.snakeCase()}}/reactive_{{originalPackageName.snakeCase()}}.dart'; | ||
import 'package:reactive_forms/reactive_forms.dart'; | ||
|
||
void main() { | ||
runApp(const MyApp()); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({Key? key}) : super(key: key); | ||
|
||
FormGroup buildForm() => fb.group({ | ||
'input': FormControl<String>(value: null), | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
visualDensity: VisualDensity.adaptivePlatformDensity, | ||
), | ||
home: Scaffold( | ||
appBar: AppBar(), | ||
body: SafeArea( | ||
child: SingleChildScrollView( | ||
physics: const BouncingScrollPhysics(), | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: 20.0, | ||
vertical: 20.0, | ||
), | ||
child: ReactiveFormBuilder( | ||
form: buildForm, | ||
builder: (context, form, child) { | ||
return Column( | ||
children: [ | ||
Reactive{{originalPackageName.pascalCase()}}<String, String>( | ||
formControlName: 'input', | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...idget_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/example/pubspec.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: reactive_{{originalPackageName.snakeCase()}}_example | ||
description: A new Flutter project. | ||
|
||
# The following line prevents the package from being accidentally published to | ||
# pub.dev using `flutter pub publish`. This is preferred for private packages. | ||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ||
|
||
# The following defines the version and build number for your application. | ||
# A version number is three numbers separated by dots, like 1.2.43 | ||
# followed by an optional build number separated by a +. | ||
# Both the version and the builder number may be overridden in flutter | ||
# build by specifying --build-name and --build-number, respectively. | ||
# In Android, build-name is used as versionName while build-number used as versionCode. | ||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning | ||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. | ||
# Read more about iOS versioning at | ||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | ||
version: 1.0.0+1 | ||
|
||
environment: | ||
sdk: ">=2.17.0 <3.0.0" | ||
|
||
# Dependencies specify other packages that your package needs in order to work. | ||
# To automatically upgrade your package dependencies to the latest versions | ||
# consider running `flutter pub upgrade --major-versions`. Alternatively, | ||
# dependencies can be manually updated by changing the version numbers below to | ||
# the latest version available on pub.dev. To see which dependencies have newer | ||
# versions available, run `flutter pub outdated`. | ||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
reactive_{{originalPackageName.snakeCase()}}: | ||
path: ../ | ||
|
||
# The following adds the Cupertino Icons font to your application. | ||
# Use with the CupertinoIcons class for iOS style icons. | ||
cupertino_icons: ^1.0.4 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
||
# The "flutter_lints" package below contains a set of recommended lints to | ||
# encourage good coding practices. The lint set provided by the package is | ||
# activated in the `analysis_options.yaml` file located at the root of your | ||
# package. See that file for information about deactivating specific lint | ||
# rules and activating additional ones. | ||
flutter_lints: ^2.0.1 | ||
|
||
# For information on the generic Dart part of this file, see the | ||
# following page: https://dart.dev/tools/pub/pubspec | ||
|
||
# The following section is specific to Flutter. | ||
flutter: | ||
|
||
# The following line ensures that the Material Icons font is | ||
# included with your application, so that you can use the icons in | ||
# the material Icons class. | ||
uses-material-design: true | ||
|
||
# To add assets to your application, add an assets section, like this: | ||
# assets: | ||
# - images/a_dot_burr.jpeg | ||
# - images/a_dot_ham.jpeg | ||
|
||
# An image asset can refer to one or more resolution-specific "variants", see | ||
# https://flutter.dev/assets-and-images/#resolution-aware. | ||
|
||
# For details regarding adding assets from package dependencies, see | ||
# https://flutter.dev/assets-and-images/#from-packages | ||
|
||
# To add custom fonts to your application, add a fonts section here, | ||
# in this "flutter" section. Each entry in this list should have a | ||
# "family" key with the font family name, and a "fonts" key with a | ||
# list giving the asset and other descriptors for the font. For | ||
# example: | ||
# fonts: | ||
# - family: Schyler | ||
# fonts: | ||
# - asset: fonts/Schyler-Regular.ttf | ||
# - asset: fonts/Schyler-Italic.ttf | ||
# style: italic | ||
# - family: Trajan Pro | ||
# fonts: | ||
# - asset: fonts/TrajanPro.ttf | ||
# - asset: fonts/TrajanPro_Bold.ttf | ||
# weight: 700 | ||
# | ||
# For details regarding fonts from package dependencies, | ||
# see https://flutter.dev/custom-fonts/#from-packages |
2 changes: 2 additions & 0 deletions
2
...forms_widget_package/__brick__/reactive_{{originalPackageName.snakeCase()}}/lib/main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// just dummy file to prevent `flutter create .` to create one | ||
// you can safely delete it |
3 changes: 3 additions & 0 deletions
3
...{{originalPackageName.snakeCase()}}/lib/reactive_{{originalPackageName.snakeCase()}}.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library reactive_{{originalPackageName.snakeCase()}}; | ||
|
||
export 'src/reactive_{{originalPackageName.snakeCase()}}.dart'; |
100 changes: 100 additions & 0 deletions
100
...iginalPackageName.snakeCase()}}/lib/src/reactive_{{originalPackageName.snakeCase()}}.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:{{originalPackageName.snakeCase()}}/{{originalPackageName.snakeCase()}}.dart'; | ||
import 'package:reactive_forms/reactive_forms.dart'; | ||
|
||
/// A [Reactive{{originalPackageName.pascalCase()}}] that contains a [{{originalPackageName.pascalCase()}}]. | ||
/// | ||
/// This is a convenience widget that wraps a [{{originalPackageName.pascalCase()}}] widget in a | ||
/// [Reactive{{originalPackageName.pascalCase()}}]. | ||
/// | ||
/// A [ReactiveForm] ancestor is required. | ||
/// | ||
class Reactive{{originalPackageName.pascalCase()}}<T, V> extends ReactiveFormField<T, V> { | ||
/// Creates a [Reactive{{originalPackageName.pascalCase()}}] that contains a [{{originalPackageName.pascalCase()}}]. | ||
/// | ||
/// Can optionally provide a [formControl] to bind this widget to a control. | ||
/// | ||
/// Can optionally provide a [formControlName] to bind this ReactiveFormField | ||
/// to a [FormControl]. | ||
/// | ||
/// Must provide one of the arguments [formControl] or a [formControlName], | ||
/// but not both at the same time. | ||
/// | ||
/// Can optionally provide a [validationMessages] argument to customize a | ||
/// message for different kinds of validation errors. | ||
/// | ||
/// Can optionally provide a [valueAccessor] to set a custom value accessors. | ||
/// See [ControlValueAccessor]. | ||
/// | ||
/// Can optionally provide a [showErrors] function to customize when to show | ||
/// validation messages. Reactive Widgets make validation messages visible | ||
/// when the control is INVALID and TOUCHED, this behavior can be customized | ||
/// in the [showErrors] function. | ||
/// | ||
/// ### Example: | ||
/// Binds a text field. | ||
/// ``` | ||
/// final form = fb.group({'email': Validators.required}); | ||
/// | ||
/// Reactive{{originalPackageName.pascalCase()}}( | ||
/// formControlName: 'email', | ||
/// ), | ||
/// | ||
/// ``` | ||
/// | ||
/// Binds a text field directly with a *FormControl*. | ||
/// ``` | ||
/// final form = fb.group({'email': Validators.required}); | ||
/// | ||
/// Reactive{{originalPackageName.pascalCase()}}( | ||
/// formControl: form.control('email'), | ||
/// ), | ||
/// | ||
/// ``` | ||
/// | ||
/// Customize validation messages | ||
/// ```dart | ||
/// Reactive{{originalPackageName.pascalCase()}}( | ||
/// formControlName: 'email', | ||
/// validationMessages: { | ||
/// ValidationMessage.required: 'The email must not be empty', | ||
/// ValidationMessage.email: 'The email must be a valid email', | ||
/// } | ||
/// ), | ||
/// ``` | ||
/// | ||
/// Customize when to show up validation messages. | ||
/// ```dart | ||
/// Reactive{{originalPackageName.pascalCase()}}( | ||
/// formControlName: 'email', | ||
/// showErrors: (control) => control.invalid && control.touched && control.dirty, | ||
/// ), | ||
/// ``` | ||
/// | ||
/// For documentation about the various parameters, see the [{{originalPackageName.pascalCase()}}] class | ||
/// and [{{originalPackageName.pascalCase()}}], the constructor. | ||
Reactive{{originalPackageName.pascalCase()}}( | ||
{Key? key, | ||
String? formControlName, | ||
FormControl<T>? formControl, | ||
ValidationMessagesFunction<T>? validationMessages, | ||
ControlValueAccessor<T, V>? valueAccessor, | ||
ShowErrorsFunction? showErrors, | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// put component specific params here | ||
}) | ||
: super( | ||
key: key, | ||
formControl: formControl, | ||
formControlName: formControlName, | ||
valueAccessor: valueAccessor, | ||
validationMessages: validationMessages, | ||
showErrors: showErrors, | ||
builder: (field) { | ||
return {{originalPackageName.pascalCase()}}( | ||
|
||
); | ||
}, | ||
); | ||
} |
Oops, something went wrong.