Flutter dart - ListView behind fixed top containers - flutter

Hi I have a problem when using pull_to_refresh package, initial loaded content is behind two top fixed containers and I dont understand behaviour of this. When I used normal RefreshIndicator, everything goes as expected. I tried to set fixed height of containers, put both containers in Column, setting Shrinkwrap false on ListView but none of those help
Code below
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 50,
child: Column(children: [
Container(
child: Container(
margin: const EdgeInsets.only(top: 10.0),
child: Text(
AppLocalizations.of(context).translate(recordType + 'Records'),
textAlign: TextAlign.center,
style: TextStyle(
fontStyle: FontStyle.normal,
color: Colors.white,
fontSize: 30.0,
shadows: [
Shadow(
blurRadius: 10.0,
color: Colors.black,
offset: Offset(3.0, 3.0),
),
],
),
),
),
),
Container(
child: Container(
margin: const EdgeInsets.only(top: 5.0),
child: Text(
args['horseName'],
textAlign: TextAlign.center,
style: TextStyle(
fontStyle: FontStyle.italic,
color: Colors.white,
fontSize: 28.0,
shadows: [
Shadow(
blurRadius: 10.0,
color: Colors.black,
offset: Offset(3.0, 3.0),
),
],
),
),
),
),
]),
),
Expanded(
child: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: WaterDropHeader(
complete: Text(AppLocalizations.of(context).translate('refreshDone'),
style: TextStyle(color: Colors.white))),
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
Widget body;
if (noMoreData) {
mode = LoadStatus.noMore;
}
if (mode == LoadStatus.idle) {
body = Text(AppLocalizations.of(context).translate('pullToLoadMore'),
style: TextStyle(color: Colors.white));
} else if (mode == LoadStatus.loading) {
body = RefreshProgressIndicator();
} else if (mode == LoadStatus.failed) {
body = Text(AppLocalizations.of(context).translate('loadFailedTryAgain'),
style: TextStyle(color: Colors.white));
} else {
body = Text(AppLocalizations.of(context).translate('noMoreData'),
style: TextStyle(color: Colors.white));
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
controller: _refreshController,
onRefresh: refreshRecords,
onLoading: fetchRecordByDateDesc,
child: ListView.builder(
return Column(children: <Widget>[
Card(
child: ListTile(

Solved with this property:
ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
primary: false,
itemCount: allRecordsChronologically?.length ?? 0,
Explanation, why primary: false ? - its a ListView.Builder within column, column is
a primary scroll, Listview is within column but must be detached from column (cannot start where the actual column starts, because it has two containers above), and because containers are fixed on top it must be scrollable from the parent widget - which is Expanded

Related

How to add an onTap with a condition to a ListView.builder in FLutter

I have a ListView builder inside a Card. In a column (in the card), each card shows a job and a list of staff members. If the staff member listed is the user who has logged in to the app, their background color is changed to highlight them in the list :
color: gblStaffId == data[index].staffId
? kMainColor20
: Colors.white,
I would like to be able to allow them to tap their own name to popup some extra details. They shouldn't be able to tap anyone else.
I think I should use an InkWell, but I'm not sure how or where to put it.
ListView.builder(
itemCount: data.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (_, int index) {
return Container(
padding: EdgeInsets.all(5.0),
margin: EdgeInsets.symmetric(vertical: 1.0),
decoration: BoxDecoration(
color: gblStaffId == data[index].staffId
? kMainColor20
: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(4)),
),
child: Row(
children: <Widget>[
Expanded(
flex: 49,
child: Text(
data[index].staffName!,
style: TextStyle(color: kBodyText, fontSize: 16),
),
),
Expanded(
flex: 23,
child: Text(
formatJsonTime24To12(data[index].startTime!)!
.toLowerCase(),
style: TextStyle(color: kBodyText, fontSize: 16),
textAlign: TextAlign.right,
),
),
Expanded(
flex: 5,
child: Text(
' -',
style: TextStyle(color: kBodyText, fontSize: 16),
textAlign: TextAlign.center,
),
),
Expanded(
flex: 23,
child: Text(
formatJsonTime24To12(data[index].finishTime!)!
.toLowerCase(),
style: TextStyle(color: kBodyText, fontSize: 16),
textAlign: TextAlign.right,
),
),
],
),
);
})
You can return Gesture widget(or any tappable) from itemBuilder. Then add ternary or conditional statement on onTap method.
physics: NeverScrollableScrollPhysics(),
itemBuilder: (_, int index) {
return GestureDetector(
onTap: gblStaffId == data[index].staffId ? () {
// your stuffs
} : null,
child: Container(
padding: EdgeInsets.all(5.0),
margin: EdgeInsets.symmetric(vertical: 1.0),
decoration: BoxDecoration(
color: gblStaffId == data[index].staffId
? kMainColor20
: Colors.white,
you can use like
onTap : gblStaffId == data[index].staffId
? funcToCall(data[index].staffId)
: null

Flutter How to show a message when flutter search filter result no result

I'm using a TextFormField to filter an array of lists using GridView to display the Items. Inside my TextFormField there I used onChanged: onSearchTextChanged, which filters through the array response from the Rest API I created which is in json. The filter works fine but I'm looking for a way around showing no result when the user inputs a filter that is not available inside the filter. Below is my code:
TextFormField is as below:
TextFormField(
controller: controller,
keyboardType: TextInputType.text,
onChanged: onSearchTextChanged,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
prefixText: ' ',
hintText: "Search",
hintStyle: TextStyle(
color: Colors.grey,fontWeight: FontWeight.normal,
fontSize: 15,
fontFamily:
'Montserrat'),
prefixIcon: Container(
child:Icon(
Icons.search,
color: Colors.grey,
size: 20,
)),
suffixIcon: backClear==true?InkWell(
onTap: () {
controller.clear();
onSearchTextChanged(
'');
},
child: Container(
child:Icon(
Icons.backspace,
color: Colors.grey,
size: 12,
))): Container(
child:Icon(
Icons.view_list_rounded,
color: Colors.grey,
size: 15,
)),
labelStyle: new TextStyle(color: Colors.grey),
),
)
onSearchTextChanged is as below:
onSearchTextChanged(String text) async {
_searchResult.clear();
if (text.isEmpty) {
setState(() {
backClear=false;
});
return;
}
content.forEach((userDetail) {
if (userDetail.username.toLowerCase().contains(text) || userDetail.username.toString().contains(text) ||
userDetail.username.toUpperCase().contains(text)||userDetail.fullname.toLowerCase().contains(text) || userDetail.fullname.toString().contains(text) ||
userDetail.fullname.toUpperCase().contains(text)||userDetail.phone.toLowerCase().contains(text) || userDetail.phone.toString().contains(text) ||
userDetail.phone.toUpperCase().contains(text)||userDetail.email.toLowerCase().contains(text) || userDetail.email.toString().contains(text) ||
userDetail.email.toUpperCase().contains(text) ) {
_searchResult.add(userDetail);
}
});
setState(() {
backClear=true;
});
}
For instance if John is not part of the return array list for username, fullname then on the screen it should show a message that says not found.
My gridview is as below:
Container(
child: _searchResult.length != 0 ||
controller.text.isNotEmpty
?new GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: _searchResult == null ? 0 : _searchResult.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount:3),
itemBuilder: (BuildContext context, int index){
return Card(
elevation: 1,
semanticContainer: true,
child:InkWell(
onTap: () async {
},
child: Container(
padding: EdgeInsets.all(10),
child:Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Column(
children: <Widget>[
Stack(
alignment: Alignment.bottomCenter,
children: [
CircleAvatar(
radius: 30,
backgroundColor: Colors.white,
child: _searchResult[index].profile_img!=null?Container(
padding: EdgeInsets.all(0),
child:CircleAvatar(
radius: 40,
backgroundImage:NetworkImage(_searchResult[index].profile_img
,),
backgroundColor: Colors.white,
//
)):Container(
padding: EdgeInsets.all(0),
child:CircleAvatar(
radius: 40,
backgroundImage:AssetImage('assets/person_icon.png'),
backgroundColor: Colors.white,
//
)),
),
],),
Flexible(
child: Center(child: Text(_searchResult[index].username==null?"AppName":_searchResult[index].username,style: TextStyle(
color: colorBlack,
fontWeight: FontWeight.normal,
fontSize: 10,
fontFamily: 'Montserrat',
),))),
Flexible(
child: Container(
padding: EdgeInsets.only(left: 15,right: 15,top: 1,bottom: 1),
decoration: BoxDecoration(
color: colorBlue,borderRadius: BorderRadius.circular(3)),
child: Text( "Follow",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 10,
fontFamily: 'Montserrat',
),
),
),)
],
),
),
]))));
;})
:GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: content == null ? 0 : content.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount:3),
itemBuilder: (BuildContext context, int index){
return Card(
elevation: 1,
semanticContainer: true,
child:InkWell(
onTap: () async {
},
child: Container(
padding: EdgeInsets.all(10),
child:Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Column(
children: <Widget>[
Stack(
alignment: Alignment.bottomCenter,
children: [
CircleAvatar(
radius: 30,
backgroundColor: Colors.white,
child: content[index].profile_img!=null?Container(
padding: EdgeInsets.all(0),
child:CircleAvatar(
radius: 40,
backgroundImage:NetworkImage(content[index].profile_img
,),
backgroundColor: Colors.white,
//
)):Container(
padding: EdgeInsets.all(0),
child:CircleAvatar(
radius: 40,
backgroundImage:AssetImage('assets/person_icon.png'),
backgroundColor: Colors.white,
//
)),
),
],),
Flexible(
child: Center(child: Text(content[index].username==null?"AppName":content[index].username,style: TextStyle(
color: colorBlack,
fontWeight: FontWeight.normal,
fontSize: 10,
fontFamily: 'Montserrat',
),))),
Flexible(
child: Container(
padding: EdgeInsets.only(left: 15,right: 15,top: 1,bottom: 1),
decoration: BoxDecoration(
color: colorBlue,borderRadius: BorderRadius.circular(3)),
child: Text( "Follow",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 10,
fontFamily: 'Montserrat',
),
),
),)
],
),
),
]))));}))
I'm not sure on where you actually display results in your sample code, but the logic you could implement is the following.
After the forEach you should check if some result is actually found, and in case it wasn't, set a showNotFoundText to true so that in your view you can display the message.
onSearchTextChanged(String text) async {
_searchResult.clear();
if (text.isEmpty) {
setState(() {
backClear=false;
showNotFoundText = false;
});
return;
}
content.forEach((userDetail) {
if (userDetail.username.toLowerCase().contains(text) || userDetail.username.toString().contains(text) ||
userDetail.username.toUpperCase().contains(text)||userDetail.fullname.toLowerCase().contains(text) || userDetail.fullname.toString().contains(text) ||
userDetail.fullname.toUpperCase().contains(text)||userDetail.phone.toLowerCase().contains(text) || userDetail.phone.toString().contains(text) ||
userDetail.phone.toUpperCase().contains(text)||userDetail.email.toLowerCase().contains(text) || userDetail.email.toString().contains(text) ||
userDetail.email.toUpperCase().contains(text) ) {
_searchResult.add(userDetail);
}
});
if (_searchResult.isEmpty) {
//Do something
setState(() {
showNotFoundText = true;
});
}
setState(() {
backClear=true;
});
}
Add something like this in your view
showNotFoundText ? Text("No results found") : Container() //Empty container instead
Since you didn't include the code for the results display, I made it this way, but you may also consider using this logic directly in your view:
_searchResult.isEmpty ? Text("No results found") : DisplayResultsWidget()
With the suggestion of Dani3le_ to use add below if statement inside my onSearchTextChanged and I declare my bool showNotFoundText = false; above my code
if (_searchResult.isEmpty) {
//Do something
setState(() {
showNotFoundText = true;
});
}
and above my Gridview I added the below to show the No result message find below the code:
showNotFoundText==true ? Text("No result found!",style: TextStyle(fontFamily: 'Montserrat',color: Colors.grey, fontSize: 13, fontWeight: FontWeight.bold),) : Container(),
But onPress of backspace the No result found still shows even if the input is available on the search list so I add showNotFoundText = false; to setState() so that every time the backspace is pressd it set the state of showNotFoundText back to false as shown below:
setState(() {
showNotFoundText = false;
});

Column: Trailing widget consumes entire tile width. Please use a sized widget, or consider replacing ListTile with a custom widget

Hello trying to learn flutter and found this great open source project, trying to get it to run locally and running into the above issue. I think the offending code is the Column within the ListTile, but can't figure out the exact issue or how to resolve, I tried adding a width/height and converting column to a container, but I don't think I got the syntax correct. Any insight is appreciated!
return StreamBuilder(
stream: usersRef.doc('$userId').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
DocumentSnapshot documentSnapshot = snapshot.data;
UserModel user = UserModel.fromJson(documentSnapshot.data());
return ListTile(
contentPadding:
EdgeInsets.symmetric(horizontal: 20.0, vertical: 5.0),
leading: Stack(
children: <Widget>[
CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'${user?.photoUrl}',
),
radius: 25.0,
),
Positioned(
bottom: 0.0,
right: 0.0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6.0),
),
height: 15,
width: 15,
child: Center(
child: Container(
decoration: BoxDecoration(
color: user?.isOnline ?? false
? Color(0xff00d72f)
: Colors.grey,
borderRadius: BorderRadius.circular(6),
),
height: 11,
width: 11,
),
),
),
),
],
),
title: Text(
'${user.username}',
maxLines: 1,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
type == MessageType.IMAGE ? "IMAGE" : "$msg",
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
SizedBox(height: 10),
TextTime(
child: Text(
"${timeago.format(time.toDate())}",
style: TextStyle(
fontWeight: FontWeight.w300,
fontSize: 11,
),
),
),
SizedBox(height: 5),
buildCounter(context),
],
),
onTap: () {
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (BuildContext context) {
return Conversation(
userId: userId,
chatId: chatId,
);
},
),
);
},
);
} else {
return SizedBox();
}
},
);

How to refresh a list widget data on a button click FLUTTER

My flutter app displays bookings for a space, and the data comes from a rest api.
The screen has a vertical and horizontal list view.
The horizontal list view contains 14 buttons, with witch the user can decide what days bookings does he want to display on the vertical list view. The problem that I have is I cant refresh the vertical list views state with the button clicks to display the correct day.
Here is where I am currently:
The vertical List View:
Widget bookingListView(List data, BuildContext context) {
if (data.isNotEmpty) {
return Container(
key: UniqueKey(),
child: Scrollbar(
showTrackOnHover: true,
isAlwaysShown: true,
controller: _horizontalScrollController,
radius: Radius.circular(32),
thickness: 5.0,
child: SingleChildScrollView(
child: ListView.builder(
scrollDirection: Axis.vertical,
controller: _horizontalScrollController,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(left: 8.0, right: 6.0),
itemCount: data.length,
itemBuilder: (context, int index) {
Bookings booking = data[index];
String fromDate = booking.from;
String toDate = booking.to;
DateFormat inputFormat = DateFormat('yyyy/MM/dd HH:mm:ss Z');
DateTime fromD = inputFormat.parse(fromDate)
.toUtc()
.add(new Duration(hours: 2));
DateTime toD = inputFormat.parse(toDate).toUtc().add(
new Duration(hours: 2));
final frmDt = fromD.toLocal();
final toDt = toD.toLocal();
String from = DateFormat('HH:mm').format(frmDt);
String to = DateFormat('HH:mm').format(toDt);
return Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 22),
child: ListTile(
title: Row(children: [
Text(
"$from",
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 48.0,
color: Color(0xfff2f2f2)),
),
Padding(
padding: const EdgeInsets.only(
left: 6.0, right: 6.0),
child: Text(
"-",
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 48.0,
color: Color(0xfff2f2f2)),
),
),
Text(
"$to",
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 48.0,
color: Color(0xfff2f2f2)),
),
]),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: const EdgeInsets.only(
top: 6.0),
child: Text(
booking.membership.name == null
? ""
: booking.membership.name,
style: TextStyle(
fontSize: booking.membership.name == null
? 0
: 40.0,
fontWeight: FontWeight.w300,
color: Color(0xfff2f2f2)),
),
),
Padding(
padding: const EdgeInsets.only(
top: 6.0),
child: Text(
booking.title == null
? ""
: booking.title ,
style: TextStyle(
fontSize:
booking.title == null
? 0
: 40.0,
fontWeight: FontWeight.w300,
color: Color(0xfff2f2f2)),
),
),
],
),
),
),
Divider(
color: Colors.white,
indent: 10.0,
endIndent: 10.0,
thickness: 0.2,
)
],
);
}),
),
),
);
} else if (data.isEmpty) {
return Container(
child: Center(
heightFactor: 7,
child: Text(
"noBooking".tr().toString(),
style: TextStyle(
fontSize: 46.0,
fontWeight: FontWeight.w300,
color: Colors.white),
),
),
);
}
return Center(child: CircularProgressIndicator());
}
And the horizontal List View:
Padding(
padding: const EdgeInsets.all(8.0),
child: FittedBox(
fit: BoxFit.fitHeight,
child: OutlinedButton(
onPressed: () async {
var from =
"${formatFrom.format(DateTime.now())}";
var to =
"${formatTo.format(DateTime.now())} 23:59";
String fromDate = from.toString();
String toDate = to.toString();
final SharedPreferences
sharedPreferences =
await SharedPreferences.getInstance();
sharedPreferences.setString(
"from", fromDate);
sharedPreferences.setString("to", toDate);
setState(() {
selectedIndex = 0;
var format = new DateFormat('MM/dd');
formattedDate =
format.format(DateTime.now());
print(selectedIndex);
Network.getBookings();
});
},
style: OutlinedButton.styleFrom(
padding: EdgeInsets.fromLTRB(
26.0, 20.0, 26.0, 20.0),
backgroundColor: selectedIndex == 0
? Color(0xfff78848)
: Color(0x66404142),
side: BorderSide(color: Colors.white)),
child: FittedBox(
fit: BoxFit.fitHeight,
child: Text(dayOne.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 22.0)),
),
),
),
),
The remaining 13 button does the same as this one, just with different from and to datetime values.
when you are adding new item to your list you have to locally add the item to you list like list.add(newItem) and then you have to call setState() which will rebuild your list and render the new item on your screen
Another solution : if you want to refreh the whole page then you can clear the previous list and toggle your loading variable and then call to your getDate() to get newly added data.
with inserting data to list will be refresed.
setState(() {
list.add(newItem); // or list.insert() can be used.
});
Otherwise, you can use button's onTap:/onPressed: with setState(() {}).
As like:
InkWell(
onTap: () => setState(() {}),
child: // widget what you want
),

Flutter: How can i put Textfield input into a list to build a ListView.builder

Im trying to build a listviewbuilder since a few days. For that i need the textfield input from another screen. I looked a lot of tutorials and question but it doesnt work.Im trying to put the input from multiple textfields into multiple lists to build a Listview builder. It would be the best if i can save all Textfield input when i press on flatbutton. I hope someone can help me.
First page
List<String> time = ["8:00"];List<String>
List<String> where = ["Am See"];
List<String> who = ["Eric"];
List<String> when = ["Donnerstag 21.4.21"];
body: SingleChildScrollView(
physics: ScrollPhysics(),
child: Column(children: [
Upperscreen(size: size),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: where.length,
itemBuilder: (BuildContext context, int Index) {
return Column(children: [
SizedBox(
height: 40,
),
Container(
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Meet1()));
},
child: Container(
width: size.width * 0.9,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(70)),
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomRight,
colors: [
Colors.green,
Colors.orange,
],
),
),
child: Column(children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
Text(
time[Index],
style: TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight:
FontWeight.bold),
),
SizedBox(
height: 10,
),
Text(
who[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
),
Text(
when[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
),
Text(
where[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
Second page
child: Column(children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
TextField(decoration: InputDecoration(hintText: " Time ")),
SizedBox(
height: 10,
),
TextField(
decoration: InputDecoration(hintText: " Who "),
),
SizedBox(
height: 10,
),
TextField(
decoration: InputDecoration(hintText: " Date "),
),
SizedBox(
height: 10,
),
TextField(
decoration: InputDecoration(hintText: " Where "),
),
SizedBox(height: 10)
],
),
),
]));
Here the Flatbutton to add all.
return FlatButton(
child: Icon(
Icons.check_circle_outline_rounded,
color: Colors.green,
size: 120,
),
onPressed: () {
Navigator.of(context).popUntil((route) => route.isFirst);
},
Use a TextEditingController(), just like this -
TextEditingController() myController = TextEditingController();
Then assign this controller to controller property in TextField() -
TextField(
controller: myController,
),
Then use myController.text to retrieve the text from TextField(), and pass it to other pages as a String parameter -
Example -
class Screen1 extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
//....
body: FlatButton(
child: Icon(
Icons.check_circle_outline_rounded,
color: Colors.green,
size: 120,
),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (builder) {
return Screen2(text: myController.text);
}));
},
//....
),
);
}
}
Second Page -
class Screen2 extends StatelessWidget {
String text;
Screen2({this.text});
#override
Widget build(BuildContext context) {
return Scaffold(
//....
body: Text(text),
);
}
}
Go to this link to see another example
Now, here I used only 1 parameter "text". You can use multiple parameters like - "text1", "text2", "text3" and so on, as per your requirement, and use as many TextEditingController() for this.
*****Also Note that use of FlatButton() is depreciated, you can use a TextButton() instead