61 lines
1.9 KiB
Dart
61 lines
1.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:prasule/pw/platformwidget.dart';
|
|
|
|
class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|
final TextEditingController? controller;
|
|
final bool? enabled;
|
|
final bool obscureText;
|
|
final String? labelText;
|
|
final bool autocorrect;
|
|
final TextInputType? keyboardType;
|
|
final List<TextInputFormatter> inputFormatters;
|
|
final void Function(String)? onChanged;
|
|
final List<String>? autofillHints;
|
|
final TextStyle? textStyle;
|
|
final TextAlign textAlign;
|
|
const PlatformField(
|
|
{super.key,
|
|
this.controller,
|
|
this.enabled,
|
|
this.labelText,
|
|
this.obscureText = false,
|
|
this.autocorrect = false,
|
|
this.keyboardType,
|
|
this.inputFormatters = const [],
|
|
this.onChanged,
|
|
this.autofillHints,
|
|
this.textStyle,
|
|
this.textAlign = TextAlign.start});
|
|
|
|
@override
|
|
TextField createAndroidWidget(BuildContext context) => TextField(
|
|
textAlign: textAlign,
|
|
controller: controller,
|
|
enabled: enabled,
|
|
obscureText: obscureText,
|
|
decoration: InputDecoration(labelText: labelText),
|
|
autocorrect: autocorrect,
|
|
keyboardType: keyboardType,
|
|
style: textStyle,
|
|
inputFormatters: inputFormatters,
|
|
onChanged: onChanged,
|
|
autofillHints: autofillHints,
|
|
);
|
|
|
|
@override
|
|
CupertinoTextField createIosWidget(BuildContext context) =>
|
|
CupertinoTextField(
|
|
textAlign: textAlign,
|
|
controller: controller,
|
|
enabled: enabled,
|
|
obscureText: obscureText,
|
|
prefix: (labelText == null) ? null : Text(labelText!),
|
|
autocorrect: autocorrect,
|
|
keyboardType: keyboardType,
|
|
inputFormatters: inputFormatters,
|
|
onChanged: onChanged,
|
|
style: textStyle,
|
|
);
|
|
}
|