Comments (2)
@kevin4dhd
Let's contextualize the scenario.
Assuming you have a registration dialog in a registration module.
in the module you have the possibility to create components in the widgets folder of this module.
You can place the dialog on one component by calling the form from another component.
I usually use a textformfield, button, in global widgets, so you can use that component inside any module without depending on another module.
An example :
class CustomTextFormField extends StatelessWidget {
final Function(String value) onSaved;
final Function(String value) onChanged;
final Function(String value) validator;
final bool emailCheck;
final String text;
final Widget sufixIcon;
final Widget prefixIcon;
final TextInputAction action;
final TextInputType type;
final bool obscure;
final TextEditingController controller;
final TextDirection direction;
final int max;
final int maxLines;
final String initialValue;
final String hintText;
final formatter;
final Color color;
final bool enable;
CustomTextFormField(
{this.maxLines = 1,
this.enable = true,
this.formatter = const <TextInputFormatter>[],
this.initialValue,
this.emailCheck,
this.text,
this.onChanged,
this.onSaved,
this.validator,
this.sufixIcon,
this.action,
this.color,
this.type,
this.obscure = false,
this.controller,
this.direction = TextDirection.ltr,
this.max,
this.prefixIcon,
this.hintText});
@override
Widget build(BuildContext context) {
return TextFormField(
enabled: this.enable,
inputFormatters: this.formatter,
maxLines: this.maxLines,
initialValue: this.initialValue,
maxLength: this.max,
textDirection: this.direction,
controller: this.controller,
obscureText: this.obscure,
style: TextStyle(fontSize: 16),
keyboardType: this.type,
cursorColor: customPrimary,
decoration: InputDecoration(
hintText: this.hintText,
hintStyle: TextStyle(color: this.color),
//contentPadding: EdgeInsets.only(top: 5),
border: UnderlineInputBorder(
borderSide: BorderSide(color: customPrimary)),
labelText: this.text,
suffixIcon: this.sufixIcon,
prefixIcon: this.prefixIcon),
onChanged: (value) => this.onChanged(value),
onSaved: (value) => this.onSaved(value),
validator: (value) => this.validator(value),
textInputAction: this.action,
);
}
}
Could be used in :
...
/app
/widgets
- custom_tff.dart
/modules
/registration
/widgets
- dialog.dart
- controller.dart
- repository.dart
- page.dart
/another
/widgets
- another_widget_using_custom_tff.dart
- controller.dart
- repository.dart
- page.dart
Where your text form field can be used in several modules as stated, or you can add it exclusively as part of that module
...
/app
/widgets
/modules
/registration
/widgets
- custom_tff.dart
- dialog.dart
- controller.dart
- repository.dart
- page.dart
And call it with Get.dialog (MyDialog ())
from getx_pattern.
Thanks 👏
from getx_pattern.
Related Issues (20)
- For larger project HOT 1
- Confused about the folder structure. HOT 1
- A working minimal example would be greatly appreciated HOT 7
- Question regarding the getx pattern HOT 3
- Do we really need the repository? HOT 2
- Dúvida no conceito de módulo HOT 5
- Duplication of initial page HOT 1
- Dúvida: onde ficariam as interfaces que são implementadas pelos `services`, `repositories` e `providers`? HOT 4
- Why is there only Android configuration under UI, IOS configuration? I don't think it makes a lot of sense HOT 1
- why folder views is double? HOT 2
- Shared controller is multiple views HOT 1
- why you dont getConnect as provider? HOT 4
- Modules... HOT 1
- Where would I put the StreamSubscription? HOT 2
- folder name: exEmples and exAmples HOT 1
- Example code HOT 1
- Site Translations HOT 4
- examples _and_ exemples? HOT 2
- Understanding the difference between Services and Providers, along with their interaction with Repositories HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from getx_pattern.