What i have ? :
Now i can enter text into blue section, after click on it keyboard shows and every widget adjust to another (by mainAxisAlignment: MainAxisAlignment.spaceAround).
What i want to have ? :
I want the same thing as i have but i want to be able to click on red section to show up keyboard. (while keeping adjusting widgets)
shortened version of
main.dart :
import 'package:flutter/material.dart';
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
GestureDetector(
child: const TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter Word",
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
child: const CustomPaint(
// foregroundPainter: LinePainter(),
),
),
const Text(
"Nie ma takowego słowa",
textAlign: TextAlign.center,
),
])));
}
To do this, you can wrap your TextField in an Expanded widget, which will expand to fill its parent and then set the expanded parameter of the TextField to true and maxLines to null. This will allow the TextField to expand to match its parent's (the Expanded widget's) height:
Expanded(
child: TextField(
expands: true,
maxLines: null,
textAlign: TextAlign.center,
textAlignVertical: TextAlignVertical.center,
),
)
If you do not want your textfield itself to expand, you need to use a
Expanded(
child: GestureDetector(
child: Center(child: TextField(focusNode: _focusNode))
),
)
and use the focusNode of the TextField to request focus for it when tapping the GestureDetector. Example here: https://docs.flutter.dev/cookbook/forms/focus. This will require using a StatefulWidget, as the focusNode is long-lived state.
final code (not shortened)
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:xmltranslator/painter.dart';
import 'package:xmltranslator/xmlreader.dart';
void main() {
runApp(const MyApp());
WidgetsFlutterBinding.ensureInitialized();
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage("text"),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage(String text, {Key? key}) : super(key: key);
#override
State<MyHomePage> createState() => _MyHomePageState();
}
final _searchValue = TextEditingController();
String _typedText = "finding txt";
String _translatedText1 = "translation";
class _MyHomePageState extends State<MyHomePage> {
#override
void initState() {
getXmlFile(context, _searchValue.text, context);
super.initState();
myFocusNode = FocusNode();
}
late FocusNode myFocusNode;
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromARGB(255, 77, 77, 77),
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 47, 47, 47),
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RichText(
text: TextSpan(children: [
TextSpan(
text: "T r a n ",
style: GoogleFonts.overpass(
fontWeight: FontWeight.bold, fontSize: 30)),
TextSpan(
text: " S l a t e",
style: GoogleFonts.overpass(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 30)),
]),
),
],
),
elevation: 20,
),
body: SafeArea(
child: Column(children: [
Expanded(
child: TextField(
textAlignVertical: TextAlignVertical.center,
style: GoogleFonts.overpass(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 23),
controller: _searchValue,
textAlign: TextAlign.center,
decoration: const InputDecoration(
border: InputBorder.none,
hintText: "Enter Word",
),
onEditingComplete: () async {
String xmlString = await DefaultAssetBundle.of(context)
.loadString("assets/test.xml");
final _translatedText2 =
await getXmlFile(context, _searchValue.text, xmlString);
setState(() {
_typedText = _searchValue.text;
});
if (xmlString.contains(_typedText)) {
setState(() {
_translatedText1 = _translatedText2.first.toString();
});
} else {
setState(() {
_translatedText1 = "Nie ma takowego słowa";
});
print("wartosc po funkcji:$_translatedText2");
}
},
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
child: CustomPaint(
foregroundPainter: LinePainter(),
),
),
Expanded(
child: Text(_translatedText1,
textAlign: TextAlign.center,
style: GoogleFonts.overpass(
color: Colors.red,
fontSize: 30,
)),
),
])));
}
}
Related
TextFormField textFormField(String text) {
text;
return TextFormField(
textAlign: TextAlign.center,
style: GoogleFonts.montserrat(),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
)),
);
}
I have created such a widget. Then I added it where I want to use it as follows.
SizedBox(
width: 80,
child: textFormField("Password"),
),
I have defined a String value in textFormField. I then called inside the code to assign this String value and entered the String value. FormField is created properly but I can't access text. I couldn't find whether the widget I gave for return is wrong or something else.
try to use controller in textFormField
use TextEditingController
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class Test extends StatefulWidget {
const Test({Key? key}) : super(key: key);
#override
State<Test> createState() => _TestState();
}
class _TestState extends State<Test> {
final textController = TextEditingController(text: "Password");
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: SizedBox(
width: 150,
child: textFormField(textController),
),
),
ElevatedButton(
onPressed: () {
print(textController.text);
},
child: const Text('call'),
),
],
),
);
}
}
TextFormField textFormField(TextEditingController controller) {
return TextFormField(
controller: controller,
textAlign: TextAlign.center,
style: GoogleFonts.montserrat(),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
)),
);
}
I'm working on my first Flutter project, I'm building a Login page, I created a variable to store a TextFormFieldController but I got the error above because I deleted the constructor.
When I return this constructor I cant declare a global variable to store the TextFormFieldController.
this is my code : (the Login page) :
import 'package:flutter/material.dart';
class LoginScreen extends StatelessWidget {
var loginUsernameController = TextEditingController();
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: const Edge
Insets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Login",
style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold),
),
const SizedBox(
height: 40,
),
TextFormField(
decoration: const InputDecoration(
labelText: "Email Address",
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.email),
),
keyboardType: TextInputType.emailAddress,
),
const SizedBox(
height: 10,
),
TextFormField(
controller: TextEditingController(),
obscureText: true,
decoration: const InputDecoration(
labelText: "Password",
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.lock),
suffixIcon: Icon(Icons.remove_red_eye),
),
keyboardType: TextInputType.emailAddress,
),
const SizedBox(
height: 20,
),
Container(
width: double.infinity,
child: MaterialButton(
onPressed: () {},
child: const Text(
"LOGIN",
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
),
)
],
),
),
);
}
}
this is the main.dart (Where I got the error) :
import 'package:flutter/material.dart';
import 'login_screen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginScreen(),
);
}
}
You need to remove const before MaterialApp :
return MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginScreen(),
);
If you create const constructor for LoginScreen widget, that will resolve the MyApp issue. But the next issue comes from var loginUsernameController = TextEditingController(); while now we have created const LoginScreen({Key? key}) : super(key: key);
For const constructor class, it requires final variables inside class level.
But TextEditingController() itself is a non-const constructor.
You can also initialize loginUsernameController inside build method while it is StatelessWidget and for StatefulWidget use initState.
Update
Added Minimal code
I want to display long text in scrollview.
Upto redline text is scrollable
I tried:
Using flexible :: Same Result
Wraping in Container :: It makes text full screen and non scrollable
Code
new Expanded(
child: new SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Text(
'Very Long text',
style: TextStyle(color: Colors.black, fontSize: 24),
)),
),
If i try to increase flex property it starts overlapping with upper widget
Thankyou
Full Code
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
backgroundColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Color(0xff010409),
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: TextField(
// controller: _uri,
decoration: InputDecoration(
hintText: 'Search', prefixIcon: Icon(Icons.search)),
),
actions: <Widget>[
FlatButton(
textColor: Colors.white,
onPressed: () {
},
child: Icon(Icons.search),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
],
),
body: SafeArea(
child: Column(children: <Widget>[
Flexible(
child: Text(
'abc',
style: TextStyle(
color: Color(0xff58a6ff), fontWeight: FontWeight.bold, fontSize: 30),
)),
new Expanded(
flex:2,
child: new SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Text(
'Big String',
style: TextStyle(color: Colors.white, fontSize: 24),
)),
),
])),
);
}
}
This snipped of code works fine for me
UPDATED:
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Color(0xff010409),
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: TextField(
// controller: _uri,
decoration: InputDecoration(
hintText: 'Search', prefixIcon: Icon(Icons.search)),
),
actions: <Widget>[
FlatButton(
textColor: Colors.white,
onPressed: () {},
child: Icon(Icons.search),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
],
),
body: SafeArea(
child: Column(children: <Widget>[
//Removed Flexible Widget
Text(
'abc',
style: TextStyle(
color: Color(0xff58a6ff),
fontWeight: FontWeight.bold,
fontSize: 30),
),
new Expanded(
// flex: 2, //commented flex here for taking the whole available space.
child: new SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Text(
"""A Long Long String Here...""",
style: TextStyle(color: Colors.white, fontSize: 24),
)),
),
])),
);
}
}
In Above Code Replace A very Long long String with your long Text
As #AK-23 Pointed out that, Are you sure you need Expanded widget above the SingleChildScrollView ?
If Yes then Paste your full Code, So that we can Figure Out the issue.
EDITED:
I have Removed the Flexible widget from the text, and commented the flex widget for the Expanded widget, and The code started working.
Wrapping the Text widget with Column worked out for me, like this:
...
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children <Widget> [
Text('Very Long text',
style: TextStyle(color: Colors.black, fontSize: 24),
),
]
)
...
I'm not sure whether or not you need the Expanded above the SingleChildScrollView
Basically I want to achieve exactly the same thing as Flutter: How to hide or show more text within certain length.
Here is my code snippet.
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final TextSpan span = TextSpan(
text: text,
style: TextStyle(
fontSize: 13,
),
);
final TextPainter textPainter = TextPainter(
text: span,
maxLines: 1,
ellipsis: '...',
textDirection: TextDirection.ltr,
);
textPainter.layout(maxWidth: constraints.maxWidth);
if (textPainter.didExceedMaxLines)
return Row(
crossAxisAlignment: _basicInformationIsExpanded
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: 13,
),
maxLines: _isExpanded ? null : 1,
//overflow: TextOverflow.ellipsis,
),
),
GestureDetector(
child: _isExpanded
? Icon(
Icons.expand_less,
)
: Icon(
Icons.expand_more,
),
onTap: () {
setState(() => _isExpanded =
!_isExpanded);
},
),
],
);
else
return Text(
text,
style: TextStyle(
fontSize: 13,
),
);
}),
The weird thing is if I comment overflow: TextOverflow.ellipsis,, everything is fine. But I need to show the ellipsis and if I add that line, the text doesn't expand when I click the icon.
Can anyone help me with it? Thanks.
You can copy paste run full code below
You can set overflow based on _isExpanded
overflow: _isExpanded ? null : TextOverflow.ellipsis,
working demo
full code
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 200,
child: ExpandText(
text: "long string" * 10,
)),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
class ExpandText extends StatefulWidget {
String text;
ExpandText({this.text});
#override
_ExpandTextState createState() => _ExpandTextState();
}
class _ExpandTextState extends State<ExpandText> {
bool _isExpanded = false;
bool _basicInformationIsExpanded = true;
#override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final TextSpan span = TextSpan(
text: widget.text,
style: TextStyle(
fontSize: 13,
),
);
final TextPainter textPainter = TextPainter(
text: span,
maxLines: 1,
ellipsis: '...',
textDirection: TextDirection.ltr,
);
textPainter.layout(maxWidth: constraints.maxWidth);
if (textPainter.didExceedMaxLines) {
print("exceed");
return Row(
crossAxisAlignment: _basicInformationIsExpanded
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 1,
child: Text(
widget.text,
style: TextStyle(
fontSize: 13,
),
maxLines: _isExpanded ? null : 1,
overflow: _isExpanded ? null : TextOverflow.ellipsis,
),
),
GestureDetector(
child: _isExpanded
? Icon(
Icons.expand_less,
)
: Icon(
Icons.expand_more,
),
onTap: () {
setState(() => _isExpanded = !_isExpanded);
},
),
],
);
} else {
print("not exceed");
return Text(
widget.text,
style: TextStyle(
fontSize: 13,
),
);
}
});
}
}
A long ago i stumbled onto same thing, surely using these widget's is a way to do this,
but here is the code which i wrote and its totally customizable.
You can change the limit variable to use it accordinly
class QNAContainer extends StatefulWidget {
final String ques;
final String answer;
QNAContainer({#required this.ques, #required this.answer});
#override
_QNAContainerState createState() => _QNAContainerState();
}
class _QNAContainerState extends State<QNAContainer> {
String truncAns;
bool showingAll = false;
int limit = 80;
#override
void initState() {
super.initState();
if (widget.answer.length > limit ) {
print("truncc");
truncAns = widget.answer.toString().substring(0, limit) + '...';
} else {
truncAns = widget.answer;
}
}
#override
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(
width: Styles.get_width(context),
height: Styles.get_height(context),
allowFontScaling: true);
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(10), vertical: ScreenUtil().setHeight(10)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: AppColors.greyFillColor.withOpacity(0.6),
),
margin: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(7)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(widget.ques,
style: TextStyle(
fontSize: ScreenUtil().setHeight(14),
fontWeight: FontWeight.bold,
)),
SizedBox(height: ScreenUtil().setHeight(5)),
Text(showingAll ? widget.answer : truncAns,
style: TextStyle(
fontSize: ScreenUtil().setHeight(14),
)),
SizedBox(height: ScreenUtil().setHeight(5)),
truncAns.contains('...')
? GestureDetector(
onTap: () {
setState(() {
showingAll = !showingAll;
});
},
child: Align(
alignment: Alignment.centerRight,
child: Container(
margin: EdgeInsets.only(bottom: ScreenUtil().setHeight(5)),
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(5), horizontal: ScreenUtil().setWidth(9)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColors.kDefaultPink),
child: Text(
showingAll ? 'see less' : 'see more',
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setHeight(14)),
),
),
),
)
: SizedBox()
],
),
);
}
}
How to clear Flutter Text Field from parent widget
I am a newbie for flutter and dart. I am developing a calculator type application.
I want to clear the text field in the TextFieldContainer1 class from my parent widget Calculator method using method function.
This is the parent widget (Calculator) which contains reset function.
class Calculator extends StatefulWidget {
#override
_CalculatorState createState() => _CalculatorState();
}
class _CalculatorState extends State<Calculator> {
double soldPrice=0.00;
reset(){
soldPrice=0.00;
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: BgColor ,
bottomNavigationBar: Container(
decoration: BoxDecoration(
borderRadius:BorderRadius.only(topLeft: Radius.circular(10), topRight:Radius.circular(10) ),
color:YellowBg,
),
alignment: Alignment.center,
height: 50,
child: Text('RESET',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
letterSpacing: 5,
),
),
),
body: SafeArea(
child: Column(
children: <Widget>[
SizedBox(height:10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
EcalLogo(logoSize: 30,),
],
),
SizedBox(height:10),
Padding(
padding:EdgeInsets.symmetric(horizontal:10.0),
child:FractionallySizedBox(
widthFactor: 0.9,
child: Container(
height:1.0,
width:130.0,
color:Colors.white,),
),),
SizedBox(height: 10,),
Expanded(
child:ListView(
children: <Widget>[
TextFieldContainer1(
title: 'SOLD PRICE',
tagLine: "SALE PRICE WITOHUT SHIPPING",
icon: Icons.check_circle,
onChange: (val) => setState(() {
soldPrice = double.parse(val);
})
),
],
))
],
),
)
);
}
}
This is the child widget class(TextFieldContainer1)
class TextFieldContainer1 extends StatefulWidget {
final String title;
final String tagLine;
final IconData icon;
final Function(String) onChange;
// Function displayFunction;
TextFieldContainer1({this.title,this.tagLine,this.icon,this.onChange});
#override
_TextFieldContainer1State createState() => _TextFieldContainer1State();
}
class _TextFieldContainer1State extends State<TextFieldContainer1> {
#override
Widget build(BuildContext context) {
return FractionallySizedBox(
widthFactor: 0.95,
child: Container(
padding: EdgeInsets.symmetric(horizontal:20, vertical:5),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: tileBackground,
),
height: 57,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:<Widget>[
Container(
child:Column(
children:<Widget>[
Row(
children:<Widget>[
Icon(widget.icon,
color:Color.fromRGBO(255, 255, 255, 0.7),
size:20
),
SizedBox(width:15),
Text(widget.title,
style: TextStyle(
fontSize: 20,
color:Colors.white,
fontWeight: FontWeight.w500
),
)
]
),
Text(widget.tagLine,
style: TextStyle(
color:Color.fromRGBO(255, 255, 255, 0.5),
fontSize: 12
),
)
]
)
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15,vertical: 5),
decoration: BoxDecoration(
color: Color.fromRGBO(252, 205, 0, 0.2),
borderRadius: BorderRadius.all(Radius.circular(10)
)
),
height: 40,
width: 92,
child: TextField(
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 20
),
autofocus: false,
decoration:InputDecoration(
focusColor: YellowBg,
fillColor: YellowBg,
hoverColor: YellowBg,
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: YellowBg),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: YellowBg),)
) ,
keyboardType: TextInputType.number,
onChanged: widget.onChange,
),
)
],
),
),
);
}
}
How to clear the text field in the TextFieldContainer1 class from my parent widget Calculator using the reset function?
make your text field accept a controller:
class TextFieldContainer1 extends StatefulWidget {
final String title;
final String tagLine;
final IconData icon;
final Function(String) onChange;
final TextEditingController controller;
// Function displayFunction;
TextFieldContainer1({this.title,this.tagLine,this.icon,this.onChange,
this.controller});
#override
_TextFieldContainer1State createState() => _TextFieldContainer1State();
}
class _TextFieldContainer1State extends State<TextFieldContainer1> {
// also don't forget to dispose the controller
#override
void dispose() {
super.dispose();
_controller.dispose();
}
}
and use it in your widget like this:
class Calculator extends StatefulWidget {
#override
_CalculatorState createState() => _CalculatorState();
}
class _CalculatorState extends State<Calculator> {
final _controller = TextEditingController();
double soldPrice=0.00;
reset(){
soldPrice=0.00;
}
#override
Widget build(BuildContext context) {
// ....
TextFieldContainer1(
title: 'SOLD PRICE',
tagLine: "SALE PRICE WITOHUT SHIPPING",
icon: Icons.check_circle,
controller: _controller,
onChange: (val) => setState(() {
soldPrice = double.parse(val);
}),
),
],
))
void reset() => _controller.clear();
// ....