import 'package:flutter/material.dart';
class FormIslemleri extends StatefulWidget {
@override
_FormIslemleriState createState() => _FormIslemleriState();
}
class _FormIslemleriState extends State<FormIslemleri> {
String girilenMetin = "";
int maxLine = 1;
FocusNode _fNode;
TextEditingController textController1;
@override
void initState() {
super.initState();
textController1=TextEditingController(text: "Varsayılan");
_fNode = FocusNode();
_fNode.addListener(() {
setState(() {
if (_fNode.hasFocus) {
maxLine = 3;
} else {
maxLine = 1;
}
});
});
}
@override
void dispose() {
_fNode.dispose();
textController1.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("İnput İşlemleri"),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FloatingActionButton(
onPressed: () {
},
child: Icon(Icons.ac_unit,),
backgroundColor: Colors.pink,
),
FloatingActionButton(
onPressed: () {
},
child: Icon(Icons.ac_unit,),mini: true,
backgroundColor: Colors.pink,
),
SizedBox(height: 10,),
FloatingActionButton(
onPressed: () {
FocusScope.of(context).requestFocus(_fNode);
},
child: Icon(Icons.ac_unit),
),
],
),
body: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
focusNode: _fNode,
autofocus: false,
controller: textController1,
maxLines: 3,
maxLength: 20,
decoration: InputDecoration(
hintText: "Buraya Bir başlık Girin",
labelText: "Başlık",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
icon: Icon(Icons.edit),
prefixIcon: Icon(Icons.done),
suffixIcon: Icon(Icons.settings),
filled: true,
fillColor: Colors.red,
),
maxLengthEnforced: true,
onChanged: (s) => debugPrint("On Change: $s"),
onSubmitted: (s) {
debugPrint("On Submit: $s");
girilenMetin = s;
},
cursorColor: Colors.pink,
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
autofocus: false,
maxLines: 3,
maxLength: 20,
decoration: InputDecoration(
hintText: "Buraya Bir başlık Girin",
labelText: "Başlık",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
icon: Icon(Icons.edit),
prefixIcon: Icon(Icons.done),
suffixIcon: Icon(Icons.settings),
filled: true,
fillColor: Colors.red,
),
maxLengthEnforced: true,
onChanged: (s) => debugPrint("On Change: $s"),
onSubmitted: (s) {
debugPrint("On Submit: $s");
girilenMetin = s;
},
cursorColor: Colors.pink,
),
),
Container(
color: Colors.teal.shade500,
margin: EdgeInsets.all(10),
width: double.infinity,
height: MediaQuery
.of(context)
.size
.height / 4,
child:
Align(alignment: Alignment.center, child: Text(girilenMetin)),
)
],
),
);
}
}