Related
I'm trying to create navigation like the below Image using a navigation rail to get the solution
But I'm unable to center the text like in the image. The paper sheets category is not in the center. How do I get the formatted center text in the first image I have posted.
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: AppColors.blue,
title: Text(subCategory.categoryTitle!),
),
body: Row(children: [
LayoutBuilder(builder: (context, constraint) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraint.maxHeight),
child: IntrinsicHeight(
child: SizedBox(
width: 80,
child: NavigationRail(
labelType: NavigationRailLabelType.all,
destinations: <NavigationRailDestination>[
for (var i = 0; i < subCategory.subCategory!.length; i++)
NavigationRailDestination(
icon: Icon(Icons.shop),
// selectedIcon: Icon(Icons.favorite),
label: Center(
child: Text(
subCategory.subCategory![i].subCategoryName!,
style: TextStyle(color: Colors.black),
),
),
),
],
selectedIndex: selected,
onDestinationSelected: (value) {
setState(() {
selected = value;
});
},
),
)),
),
);
}),
]),
),
);
Use textAlign: TextAlign.center, on lavbel Text.
label: Text(
"${subCategory.subCategory?[i].subCategoryName}", //null acceptation
textAlign: TextAlign.center, //this
style: TextStyle(color: Colors.black),
),
I have DataTable in flutter which is working fine until I got an empty list. In case the widget.detailDate.brands is empty, I get "Bad state: No element" error, now my question is, how can I handle the error, I've tried something like
widget.detailDate.brands.map((brand) => {
if (brand != ' '){
// do the DataRow stuff
}else{
print('brnad not found')
}
}).toList();
But it's not working. I wanna add something like "-", if the list is empty
My whole code looks like this:
DataTable buildBrandTable(context) {
return DataTable(
columnSpacing: 0,
showCheckboxColumn: false,
columns: const <DataColumn>[
DataColumn(
label: Text(
'Brand',
),
),
DataColumn(
label: Text(
'Mandant',
),
),
DataColumn(
label: Expanded(
child: Text(
'Januar',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Februar',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'März',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'April',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Mai',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Juni',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Juli',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'August',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'September',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Oktober',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'November',
textAlign: TextAlign.end,
),
)),
DataColumn(
label: Expanded(
child: Text(
'Dezember',
textAlign: TextAlign.end,
),
),
),
],
rows: [
...widget.detailData.brands!
.map(
(brand) => DataRow(
onSelectChanged: (bool) {
Navigator.of(context)
.pushNamed(DetailScreen.routeName, arguments: {
'pageType': 'Brand',
'id': brand['brand_slug'].toString(),
});
},
color: (brand['brand'] == 'Gesamt')
? MaterialStateProperty.resolveWith(
(Set<MaterialState> states) => Colors.grey[300])
: null,
cells: [
DataCell(Text(brand['brand'])),
DataCell(Text(brand['mandant'])),
..._month
.map(
(month) => DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(formatter.format(brand[month])),
],
),
),
)
.toList(),
DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
formatter.format(
_month
.map((month) => brand[month])
.toList()
.reduce((a, b) => a + b),
),
),
],
),
),
DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text((brand['rate'] != null)
? formatterPercent.format(brand['rate'] / 100)
: 'N/A'),
],
),
),
DataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text((brand['rate_letztes_jahr'] != null)
? formatterPercent
.format(brand['rate_letztes_jahr'] / 100)
: 'N/A')
],
),
),
],
),
)
.toList(),
],
);
}
I think your problem is caused by
rows: [
...widget.detailData.brands!
.map( // rest of your mapping function
...
maybe you should
widget.detailData.brands.length>0 ?
...widget.detailData.brands.map( // rest of your mapping function
:
[]
in your widget tree
Update
for example
Using the spread operator(...), adds the items individually not as a list
Column(
children: [
...values.map((value) {
return Text(value);
}),
],
),
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: const Icon(Icons.home),
automaticallyImplyLeading: true,
title: const Text('test app'),
foregroundColor: Colors.black,
actions: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.menu),
),
],
),
body: Container(
child: Column(
children: [
Row(
children: [
const Text(
'New',
style: TextStyle(
color: Colors.black54,
fontSize: 40,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
height: 2,
shadows: [
Shadow(color: Colors.black12, offset: Offset(4, 10))
]),
),
ElevatedButton.icon(onPressed: (){}, icon: Icon(Icons.navigate_next),label: Text(' '),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.grey),
),
),
],
),
Row(),
],
),
),
),
);
}
use the Row widget properties for laying out its childrens
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [....]
)
the official docs are helpful in that matter
https://api.flutter.dev/flutter/widgets/Row-class.html
sidenote: if you are not planning to use any of the first container() properties then its better to get rid of it
There are 4 options u can use depending on what you want
If u want it below new u can use Column instead of Row .
If u want to put some space next to new u can use SizedBox(width:X) between the Text and the elevated button.
You can use mainAxisAlignment or crossAxisAlignment inside the row or column to customize the position
you can find examples about them here https://docs.flutter.dev/development/ui/layout
you can use margin or padding on elevated button to customize its own position
In this, when the uniq_id of the button and the uniq_id of the data table match, only then the data of the user of that uniq_id will show.
But this error is coming before the data shows.
Did show the data for one time but after this error came, for both the page
This is my p_team.dart
This is the part of the button that is coming from the Api.
import 'package:flutter/material.dart';
import 'package:practice/listPost/p_team_list.dart';
import 'package:practice/post/post.dart';
import 'package:practice/post/services.dart';
class PTeam extends StatefulWidget {
#override
_PTeamState createState() => _PTeamState();
}
class _PTeamState extends State<PTeam> with SingleTickerProviderStateMixin {
List<Post>? posts;
#override
void initState() {
Services().getPosts().then((list) {
(() {
posts = list;
print(posts);
});
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Container(
margin: const EdgeInsets.all(20.0),
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(width: 2, color: Colors.greenAccent)),
child: Row(
children: [
Text(
"Total Income:",
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic),
),
SizedBox(
width: 10.0,
),
Text(
"Rs.2000",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic),
),
],
),
),
SizedBox(
height: 20.0,
),
Flexible(
child: Container(
child: GridView.count(
childAspectRatio: 1.0,
padding: EdgeInsets.only(left: 16, right: 16),
crossAxisCount: 2,
crossAxisSpacing: 18,
mainAxisSpacing: 18,
children: List.generate(
posts!.length,
(index) => GestureDetector(
onTap: () {
print(posts![index].teamUniqId);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PTeamList(
teamUniqId: posts![index].teamUniqId,
teamType: posts![index].teamType,
)),
);
},
child: Container(
decoration: BoxDecoration(
color: Color(0xff00ffaa),
borderRadius: BorderRadius.circular(10)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Center(
child: Text(posts![index].teamType,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600)),
),
],
),
),
),
),
),
),
),
],
),
);
}
}
This is my button api's data for p_team.dart.
[{"teamType":"direct team","team_name":"platinum","team_number":"234","team_uniq_id":"1","team_last_update":"10-may-2021"},{"teamType":"left team","team_name":"gold","team_number":"356","team_uniq_id":"2","team_last_update":"10-may-2021"},{"teamType":"right team","team_name":"silver","team_number":"876","team_uniq_id":"3","team_last_update":"10-may-2021"}]
this is my p_team_list.dart.
In this, when the uniq_id of the button and the uniq_id of the data table match, only then the data of the user of that uniq_id will show.
import 'package:flutter/material.dart';
import 'package:practice/listPost/post_list.dart';
import 'package:practice/listPost/services.dart';
class PTeamList extends StatefulWidget {
final teamUniqId;
final teamType;
const PTeamList({Key? key, this.teamUniqId, this.teamType}) : super(key: key);
#override
_PTeamListState createState() => _PTeamListState();
}
class _PTeamListState extends State<PTeamList> {
List<Post>? posts;
#override
void initState() {
Services().getPosts().then((list) {
setState(() {
posts = list;
print("za$posts");
});
});
}
#override
Widget build(BuildContext context) {
// if(widget.teamUniqId==posts.)
return Scaffold(
body:
// Text(widget.teamType),
Flexible(
child: Container(
child: Stack(
children: List.generate(posts!.length, (index) {
if (posts!.length == null) {
print(posts![index].user);
return Center(child: CircularProgressIndicator());
}
else if (widget.teamUniqId == posts![index].teamUniqId) {
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
// Data table widget in not scrollable so we have to wrap it in a scroll view when we have a large data set..
child: SingleChildScrollView(
child: DataTable(
columns: [
// DataColumn(
// label: Text('Verified'),
// tooltip: 'represents if user is verified.'),
DataColumn(
label: Text('S No'),
tooltip: 'represents first S no of the user'),
DataColumn(
label: Text('Sponsor ID'),
tooltip: 'represents Sponsor ID of the user'),
DataColumn(
label: Text('User ID'),
tooltip: 'represents User ID of the user'),
DataColumn(
label: Text('Name'),
tooltip: 'represents Name of the user'),
DataColumn(
label: Text('Mobile'),
tooltip: 'represents Mobile of the user'),
DataColumn(
label: Text('Date'),
tooltip: 'represents Date of the user'),
DataColumn(
label: Text('a'),
tooltip: 'represents Date of the user'),
DataColumn(
label: Text('b'),
tooltip: 'represents Date of the user'),
DataColumn(
label: Text('c'),
tooltip: 'represents Date of the user'),
DataColumn(
label: Text('d'),
tooltip: 'represents Date of the user'),
],
rows: posts![index]
.user
.map((data) =>
DataRow(
cells: [
// I want to display a green color icon when user is verified and red when unverified
DataCell(Text(data.userName)),
DataCell(Text(data.userMotherName)),
DataCell(Text(data.userAddress)),
DataCell(Text(data.userSponsorId)),
DataCell(Text(data.sponsorId)),
DataCell(Text(data.email)),
DataCell(Text(data.city)),
DataCell(Text(data.state)),
DataCell(Text(data.userMobile)),
DataCell(Text(data.dob)),
]))
.toList(),
),
),
);
}
return Text("");
}),
),
),
),
);
}
}
This is my data table api's data for p_team.dart.
[{"teamType":"direct Team","team_uniq_id":"1","user":[{"user_name":"deepak","user_mother_name":"Accomodation","user_address":"varanasi","user_mobile":"5678989","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"},{"user_name":"deepak","user_mother_name":"Accomodation","user_address":"varanasi","user_mobile":"5678989","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"},{"user_name":"deepak","user_mother_name":"Accomodation","user_address":"varanasi","user_mobile":"5678989","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"}]},{"teamType":"left Team","team_uniq_id":"2","user":[{"user_name":"Ashu","user_mother_name":"manju","user_address":"Mirzapur","user_mobile":"222222","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"},{"user_name":"Ashutodh","user_mother_name":"manju1","user_address":"Mirzapur1","user_mobile":"2222221","user_sponsor_id":"1234561","sponsor_id":"34561","email":"abc#gmai.com1","city":"varanasi1","state":"India1","dob":"12-5-19961"}]},{"teamType":"Right Team","team_uniq_id":"3","user":[{"user_name":"tosh","user_mother_name":"snju","user_address":"Allahabad","user_mobile":"44444444","user_sponsor_id":"333456","sponsor_id":"6666666","email":"jkl#gmai.com","city":"lucknow","state":"India","dob":"15-3-1956"}]},{"teamType":"Total Team","team_uniq_id":"4","user":[{"user_name":"tosh","user_mother_name":"snju","user_address":"Allahabad","user_mobile":"44444444","user_sponsor_id":"333456","sponsor_id":"6666666","email":"jkl#gmai.com","city":"lucknow","state":"India","dob":"15-3-1956"},{"user_name":"deepak","user_mother_name":"Accomodation","user_address":"varanasi","user_mobile":"5678989","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"},{"user_name":"deepak","user_mother_name":"Accomodation","user_address":"varanasi","user_mobile":"5678989","user_sponsor_id":"123456","sponsor_id":"3456","email":"abc#gmai.com","city":"varanasi","state":"India","dob":"12-5-1996"},{"user_name":"tosh","user_mother_name":"snju","user_address":"Allahabad","user_mobile":"44444444","user_sponsor_id":"333456","sponsor_id":"6666666","email":"jkl#gmai.com","city":"lucknow","state":"India","dob":"15-3-1956"}]}]
The cause of this issue is that you're using a bang ! operator on a null value. This indicates that the Object can't be null, and throws an error if so.
You can either add a null check at the start or if the value can be null, it's best to use a nullable ? operator instead.
The error can be easily demonstrated with
int? foo; // nullable var
debugPrint('${foo!}'); // with the ! operator, Flutter expects the value to never be null
I have been trying again today to center the title of a Flutter ListTile. Over the past few days I have spent an hour or two Googling and trying things then loosing my cool and giving up.
I am just learning Flutter and love the concept but can find no video training courses (Lynda.com, uDemy.com etc). I have read through the relevant documentation but cannot get rid of all the red lines that appear when I try to apply them to my code.
There must be logic in the syntax but after 2 weeks I have not worked it out yet.
Back to the problem, I have tried
List<Widget> list = <Widget>[
new ListTile(
new child: Center (
title:
new Text('Title 1',
style: new TextStyle(
fontWeight: FontWeight.w500,
color: Colors.deepOrangeAccent,
fontSize: 25.0)),
)
),
];
List<Widget> list = <Widget>[
new ListTile(
title:
new child: Center (
new Text('Title 2',
style: new TextStyle(
fontWeight: FontWeight.w500,
color: Colors.deepOrangeAccent,
fontSize: 25.0)),
)
),
];
List<Widget> list = <Widget>[
new ListTile(
child: Center
title: (
new Text('Title 3',
style: new TextStyle(
fontWeight: FontWeight.w500,
color: Colors.deepOrangeAccent,
fontSize: 25.0)),
)
),
];
List<Widget> list = <Widget>[
new ListTile(
title: Center
new Text('Title 4',
style: new TextStyle(
fontWeight: FontWeight.w500,
color: Colors.deepOrangeAccent,
fontSize: 25.0)),
)
),
];
Please help me with this problem and also where to find a video course on Flutter?
On the upside, if this continues I will no longer be grey, I will be bald instead.
I thought I worked it out when I added 'textAlign: TextAlign.center,' to the text object. There were no red lines but the text was still left aligned.
I am not sure what have you tried, but you in order to center the title of the ListTile you can use a center widget like you did in your code, or wrap your text within a Row widget and set mainAxisAlignment: MainAxisAlignment.center.
Using Center widget:
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("ListTile Example"),),
body: new ListView(
children: new List.generate(7, (int index) {
return new ListTile(
title: new Center(child: new Text("Centered Title#$index",
style: new TextStyle(
fontWeight: FontWeight.w500, fontSize: 25.0),)),
subtitle: new Text("My title is centered"),
);
}),
),
);
}
Using Row widget:
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("ListTile Example"),),
body: new ListView(
children: new List.generate(7, (int index) {
return new ListTile(
title: new Row(children: <Widget>[new Text("Centered Title#$index",
style: new TextStyle(
fontWeight: FontWeight.w500, fontSize: 25.0),)
], mainAxisAlignment: MainAxisAlignment.center,),
subtitle: new Text("My title is centered"),
);
}),
),
);
}
However, your problem is not about centering the title, it is about you are trying to insert too big of a Text inside a small area, that is why you are getting the red lines, so one solution is choose a smaller fontSize, a better solution is to get rid of ListTile and build your own custom widget, since a ListTile is
A single fixed-height row that typically contains some text as well as
a leading or trailing icon.
So it should not be used if you are using bigger widgets.
This is simple example of how to create a custom widget that resembles ListTile, but is more flexible and customizable when dealing with larger items:
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("ListTile Example"),),
body: new ListView(
children: new List.generate(7, (int index) {
return new Container(
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 20.0),
child: new Column(
children: <Widget>[
new Align (child: new Text("Centered Title $index",
style: new TextStyle(fontSize: 40.0),), //so big text
alignment: FractionalOffset.topLeft,),
new Divider(color: Colors.blue,),
new Align (child: new Text("Subtitle $index"),
alignment: FractionalOffset.topLeft,),
new Divider(color: Colors.blue,),
new Align (child: new Text("More stuff $index"),
alignment: FractionalOffset.topLeft,),
new Row(mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ //add some actions, icons...etc
new FlatButton(onPressed: () {}, child: new Text("EDIT")),
new FlatButton(onPressed: () {},
child: new Text("DELETE",
style: new TextStyle(color: Colors.redAccent),))
],),
],
),
);
}),
)
);
}
You can change the alignment of the text by using textAlign
Use this to center the Title of a ListTile:
ListTile(title: Text('YOUR TEXT', textAlign: TextAlign.center));
Here is my example of a three-row tile:
class ThreeRowTile extends StatelessWidget {
final Widget title;
final Widget detail;
final String utility1;
final String utility1Help;
final String utility2Help;
final String utility2;
final Icon icon;
final String cell;
final String home;
final String office;
final String email;
final VoidCallback cellTapped;
final VoidCallback cellLongPressed;
final VoidCallback iconTapped;
ThreeRowTile({
this.title,
this.icon,
this.detail,
this.utility1,
this.utility1Help,
this.utility2,
this.utility2Help,
this.cellTapped,
this.home,
this.email,
this.cell,
this.office,
this.cellLongPressed,
this.iconTapped,
});
#override
Widget build(BuildContext context) {
List<Widget> buildChildren() {
List<Widget> builder = [];
if (cell.isNotEmpty && !cell.toString().contains("--")) {
builder.add(ListTile(
leading: const Icon(Icons.phone),
title: Text(
'Cell',
textScaleFactor: globals.textScaleFactor,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
cell.toString().length > 0 ? cell : "No Number Found",
textScaleFactor: globals.textScaleFactor,
),
onTap: cell.toString().contains("--")
? null
: () {
globals.Utility.makePhoneCall(context, cell);
},
));
}
if (office.isNotEmpty && !office.toString().contains("--")) {
builder.add(ListTile(
leading: const Icon(Icons.work),
title: Text(
'Office',
textScaleFactor: globals.textScaleFactor,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
office.toString().length > 0 ? office : "No Number Found",
textScaleFactor: globals.textScaleFactor,
),
onTap: office.toString().contains("--")
? null
: () {
globals.Utility.makePhoneCall(context, office);
},
));
}
if (home.isNotEmpty && !home.toString().contains("--")) {
builder.add(ListTile(
leading: const Icon(Icons.home),
title: Text(
'Home',
textScaleFactor: globals.textScaleFactor,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
home.toString().length > 0 ? home : "No Number Found",
textScaleFactor: globals.textScaleFactor,
),
onTap: home.toString().contains("--")
? null
: () {
globals.Utility.makePhoneCall(context, home);
},
));
}
if (email.isNotEmpty && !email.contains('No Email Address')) {
builder.add(ListTile(
leading: const Icon(Icons.email),
title: Text(
'Email',
textScaleFactor: globals.textScaleFactor,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
email.toString().length > 0 ? email : "No Email Found",
textScaleFactor: globals.textScaleFactor,
),
onTap: email.toString().isEmpty
? null
: () {
globals.Utility.sendEmail(context, email);
},
));
}
if (builder.isEmpty) {
builder.add(
ListTile(
leading: const Icon(Icons.info),
title: Text(
'No Contact Information Found',
textScaleFactor: globals.textScaleFactor,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
);
}
return builder;
}
String _utility1 =
utility1 == null || utility1.contains("1-1-1800") ? "" : utility1;
String _utility2 =
utility2 == null || utility2.contains("1-1-1800") ? "" : utility2;
var rowCard = Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey[300]))),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 5.0),
child: new Column(
children: <Widget>[
Row(
children: <Widget>[
Align(
child: IconButton(
icon: icon,
onPressed: iconTapped,
),
alignment: FractionalOffset.centerLeft,
),
Expanded(
child: Column(
children: <Widget>[
new Align(
child: title, //so big text
alignment: FractionalOffset.topLeft,
),
// new Divider(),
new Align(
child: detail,
alignment: FractionalOffset.topLeft,
),
// new Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
child: Container(
margin: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(
border: Border.all(
color: _utility1.length > 1
? Colors.grey
: Colors.transparent)),
child: Tooltip(
message:
utility1Help == null ? "" : utility1Help,
child: Text(
_utility1,
maxLines: 1,
textAlign: TextAlign.center,
textScaleFactor: globals.textScaleFactor,
),
),
),
),
Expanded(
child: Container(
margin: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(
border: Border.all(
color: _utility2.length > 1
? Colors.grey
: Colors.transparent)),
child: Tooltip(
message: utility2 == null ? "" : utility2,
child: Text(
_utility2,
maxLines: 1,
textAlign: TextAlign.center,
textScaleFactor: globals.textScaleFactor,
),
),
),
),
],
),
],
),
),
Align(
child: IconButton(
icon: Icon(Icons.arrow_drop_down),
onPressed: () {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
child: Padding(
padding: EdgeInsets.only(bottom: 10.0),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: buildChildren()),
),
));
});
},
),
alignment: FractionalOffset.centerRight,
),
],
),
],
),
),
// color: globals.isDarkTheme ? Colors.black45 : Colors.white,
);
return (rowCard);
}
}
And it can be used like this:
ThreeRowTile(
icon: Icon(Icons.person),
title: _contacts?.items[index]?.lastName.toString().isEmpty &&
_contacts?.items[index]?.firstName.toString().isEmpty
? null
: Text(
(_contacts?.items[index]?.lastName ?? "") +
", " +
(_contacts?.items[index]?.firstName ?? ""),
textScaleFactor: globals.textScaleFactor,
),
detail: Text(
_contacts?.items[index]?.lastActivity,
textScaleFactor: globals.textScaleFactor,
),
utility1: _contacts?.items[index]?.dateCreated,
utility1Help: 'Date Created',
utility2: _contacts?.items[index]?.dateModified,
utility2Help: "Date Modified",
cell: _contacts?.items[index]?.cell,
home: _contacts?.items[index]?.home,
office: _contacts?.items[index]?.office,
email: _contacts?.items[index]?.email,
cellTapped: () {
globals.contactID = _contacts?.items[index]?.contactID;
Navigator.of(context).pushNamed("/contact_details").then((value) {
if (globals.infoChanged) {
_getData("", false).then((newitems) {
setState(() {
_contacts = newitems;
});
});
}
});
},
);