'Empty value in TextFormField
This is an AlertDialog, when the person types the name, the name cannot be null or empty.
import 'package:flutter/material.dart';
abstract class ComponentDialog {
static final TextEditingController _controller = TextEditingController();
static Future<dynamic> BuidDialog(
BuildContext context,
String titleLabel,
String inputLabel,
String cancelLabel,
String confirmLabel,
) =>
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(titleLabel),
content: TextFormField(
controller: _controller,
decoration: InputDecoration(
labelText: inputLabel,
border: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.pinkAccent, // TODO: charge color
),
),
),
),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(cancelLabel),
),
TextButton(
onPressed: () {
if (stringTitleLabel.IsNullOrWhiteSpace(objeto)) {
return;
}
Navigator.pop(context, _controller.text);
},
child: Text(confirmLabel),
),
],
),
);
}
Solution 1:[1]
Padding(
padding: EdgeInsets.only(left: 2.0, top: 1.0, right: 120.0, bottom: 4.0),
child: Text(
'name', //username
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16,),
),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ouflak |
