Creating Time In and Out in Flutterflow - flutter

Is there a way how can I create a time in / out in flutterflow? What actions do I need to add? Thank you here's a screenshot of my app created in flutterflow.

I've created a complete widget, according to your screenshot and question. You have to implement your own logic to save time in/out somewhere and fix layout as you want but here is:
import 'package:flutter/material.dart';
class TimeScreen extends StatefulWidget {
const TimeScreen({Key? key}) : super(key: key);
#override
TimeScreenState createState() => TimeScreenState();
}
class TimeScreenState extends State<TimeScreen> {
String timeIn = '', timeOut = '';
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 30.0),
Row(
children: const [
Text(
'Atendance',
style: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
),
Expanded(
child: Align(
alignment: Alignment.center,
child: Icon(
Icons.flutter_dash,
size: 40.0,
color: Colors.orange,
),
),
),
],
),
const SizedBox(height: 16.0),
const Text(
'[Display Name]',
style: TextStyle(
color: Colors.grey,
),
),
const SizedBox(height: 32.0),
Center(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: Card(
color: Colors.white,
elevation: 2,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 32.0,
),
child: Row(
children: [
Expanded(
child: Column(
children: [
const Text(
'Time In',
style: TextStyle(
fontSize: 18.0,
),
),
Text(
timeIn.isEmpty ? '--/--' : timeIn,
style: const TextStyle(
fontSize: 24.0,
color: Colors.orange,
fontWeight: FontWeight.bold,
),
),
],
),
),
Expanded(
child: Column(
children: [
const Text(
'Time Out',
style: TextStyle(
fontSize: 18.0,
),
),
Text(
timeOut.isEmpty ? '--/--' : timeIn,
style: const TextStyle(
fontSize: 24.0,
color: Colors.orange,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
),
),
),
),
const SizedBox(height: 32.0),
const Center(
child: Text(
'Time Time Widget',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 32.0),
Center(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.5,
height: 45.0,
child: OutlinedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.orange),
side: MaterialStateProperty.all(
const BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
),
),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Time In',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
),
onPressed: () => createStartTime(),
),
),
),
const SizedBox(height: 32.0),
Center(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.5,
height: 45.0,
child: OutlinedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.orange),
side: MaterialStateProperty.all(
const BorderSide(
color: Colors.orange,
style: BorderStyle.solid,
),
),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Time Out',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
),
onPressed: () => createEndTime(),
),
),
),
],
),
),
),
);
}
createStartTime() {
/** Implement your logic to save time data */
setState(() {
timeIn = TimeOfDay.now().format(context);
});
}
createEndTime() {
/** Implement your logic to save time data */
setState(() {
timeOut = TimeOfDay.now().format(context);
});
}
}
resulting in:

Related

Stack item are not positioned when the screen size changes Flutter

1-I am making a simple app where I am creating Profile section Where there is Stack at the top with two widgets
but the problem is when ever I test the app on different screen sizes the Stack item widgets are not at same position even i tried with MediaQuery
2-And the Second issue is I want the Circle Avatar to be place Half inside the Container And Half Out-side the Container.
Here is my Profile.dart class
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
#override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
// height: mediaQueryData.size.height * 0.4,
height: 300,
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Colors.black,
Color.fromRGBO(255, 243, 18, 3),
], begin: Alignment.topLeft, end: Alignment.bottomRight),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50))),
),
const Padding(
padding: EdgeInsets.only(top: 240, left: 140),
child: CircleAvatar(
backgroundColor: Color.fromARGB(183, 40, 46, 3),
radius: 50,
child: Text(
"M-E",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 32),
),
),
),
Positioned(
top: 110,
left: 40,
child: Text(
"مثابة ايلاف",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 70),
),
),
//),
],
),
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 0),
child: ListTile(
trailing: const Icon(
Icons.cast_for_education,
color: Colors.black,
),
title: const Text(
"Subjects (مضامین)",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),
),
onTap: () {},
),
),
const Divider(
color: Colors.black,
thickness: 0.5,
),
Padding(
padding: const EdgeInsets.only(top: 2),
child: ListTile(
trailing: const Icon(
Icons.contacts,
color: Colors.black,
),
title: const Text(
"Contact (رابطہ )",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),
),
onTap: () {},
),
),
const Divider(
color: Colors.black,
thickness: 0.5,
),
Padding(
padding: const EdgeInsets.only(top: 2),
child: ListTile(
trailing: const Icon(
Icons.settings,
color: Colors.black,
),
title: const Text(
"Setting (ترتیبات)",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),
),
onTap: () {},
),
),
const Divider(
color: Colors.black,
thickness: 0.5,
),
Padding(
padding: const EdgeInsets.only(top: 2),
child: ListTile(
trailing: const Icon(
Icons.logout,
color: Colors.black,
),
title: const Text(
"Logout (لاگ آوٹ)",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),
),
onTap: () {},
),
),
],
),
],
),
));
}
}
Here is the const result I want when the app run on different devices
Here is the result I don't want to be happens whenever the device size changes
Use this structure.
Positioned(
top: 110,
left: 1,
right:1
child: Text(
"مثابة ايلاف",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 70),
),
),

Move elements in ConstrainedBox

I have a code that is responsible for displaying the characteristics of the device.
I put these characteristics in Column, wrapped Card, and listed everything.
I am attaching a short code example.
Container(
constraints: const BoxConstraints(maxWidth: 800),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
color: Colors.black,
width: 2,
),
),
child: Card(
child: Column(
children: [
Text(
'Location:',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
Text(
device.location,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w500),
),
const Divider(
color: Colors.black, endIndent: 10, indent: 10),
Text(
'Status:',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 250),
child: Padding(
padding:
const EdgeInsets.fromLTRB(30, 0, 0, 0),
child: Row(children: [
Expanded(
child: Text(
device.status.toString().substring(7),
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500),
),
),
Expanded(
child: (device.status == Status.booked)
? OutlinedButton(
onPressed: () async {
final user = await user_api
.getUser(device.userId);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const UserCard(),
settings: RouteSettings(
arguments:
user, //TODO: check route
),
),
);
},
child: const Text("User",
style: TextStyle(
fontSize: 15,
color: Colors.black,
)),
style: OutlinedButton.styleFrom(
fixedSize: const Size(100, 15),
side: BorderSide(
width: 1.0,
color: Colors.black),
backgroundColor:
Colors.yellow[600],
),
)
: Text(''),
),
]))),
const Divider(
color: Colors.black, endIndent: 10, indent: 10),
],
),
),
),
const SizedBox(
height: 5,
),
Photo how it looks
But I would like to move the "User" button in the status column to the right. Tell me how can I do this?
The barrier is coming from BoxConstraints(maxWidth: 250). To handle view in row, we can use Row with mainAxisAlignment: MainAxisAlignment.spaceBetween, with Expanded 3 children for separation, also while using padding, provide save value on both side.
ConstrainedBox(
constraints:
const BoxConstraints(), //remove width, you can remove ConstrainedBox widget
child: Padding(
padding: const EdgeInsets.fromLTRB(
30, 0, 30, 0), // prvide same padding
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Expanded(
child: SizedBox()), //handle left sepration
const Expanded(
child: Text(
"device",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.w500),
),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: OutlinedButton(
onPressed: () async {},
child: const Text("User",
style: TextStyle(
fontSize: 15,
color: Colors.black,
)),
style: OutlinedButton.styleFrom(
fixedSize: const Size(100, 15),
side: BorderSide(
width: 1.0, color: Colors.black),
backgroundColor: Colors.yellow[600],
),
),
),
)
]))),

Navigate back from page flutter

I want to navigate to the previous page using the arrow icon I have added in this code. to where I want to add that code and tell me how to code that part. want to navigate from detail_screen.dart to home_page.dart using the arrow icon I have added. can someone please provide a proper answer for this?
detail_screen.dart
import 'package:flutter/material.dart';
class DetailsScreen extends StatelessWidget {
const DetailsScreen({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
//shadowColor: Colors.transparent,
leading: Icon(
Icons.arrow_back_rounded,
color: Colors.black,
),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: const [
CircleAvatar(
radius: 40,
backgroundColor: Colors.white,
child:
Icon(Icons.favorite_border_outlined, color: Colors.black),
),
CircleAvatar(
radius: 40,
backgroundColor: Colors.white,
child: Icon(Icons.shopping_bag_outlined, color: Colors.black),
)
],
),
),
],
),
body: Column(
children: <Widget>[
Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 0),
child: Container(
height: MediaQuery.of(context).size.height * 0.9,
width: MediaQuery.of(context).size.width * 0.9,
padding: const EdgeInsets.only(left: 20),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image23.png"),
fit: BoxFit.contain,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20,
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.grey.shade100,
),
alignment: const Alignment(1, 1),
height: 310,
width: 375,
child: Column(
children: [
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
"Crop Top",
style: TextStyle(
fontSize: 24,
color: Color(0xff262626),
fontWeight: FontWeight.w700),
textAlign: TextAlign.left,
),
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 25,
height: 25,
child: FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.blueAccent,
child: null),
),
),
SizedBox(
width: 25,
height: 25,
child: FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.amber,
child: null),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: SizedBox(
width: 25,
height: 25,
child: FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.lightGreen,
child: null),
),
),
]),
],
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 270, 10),
child: Text(
"Sizes",
style: TextStyle(
fontSize: 16,
color: Color(0xff262626),
fontWeight: FontWeight.w700),
textAlign: TextAlign.left,
),
),
// SizedBox(
// height: 30,
// ),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.black,
),
),
onPressed: () {
print('XS');
},
child: Text('XS'),
),
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.black,
),
),
onPressed: () {
print('X');
},
child: Text('S'),
),
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.black,
),
),
onPressed: () {
print('M');
},
child: Text('M'),
),
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.black,
),
),
onPressed: () {
print('L');
},
child: Text('L'),
),
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.black,
),
),
onPressed: () {
print('XL');
},
child: Text('XL'),
),
],
),
SizedBox(
height: 30,
),
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"30% off",
style: TextStyle(
fontSize: 25,
color: Colors.purple,
fontWeight: FontWeight.w700),
),
),
],
),
SizedBox(
height: 30,
),
Row(
children: const [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Rs.2950",
style: TextStyle(
fontSize: 18,
color: Color(0xff8399A9),
fontWeight: FontWeight.w700,
decoration: TextDecoration.lineThrough),
),
),
Text(
"Rs.2750",
style: TextStyle(
fontSize: 24,
color: Color(0xff0DA75F),
fontWeight: FontWeight.w700,
),
),
],
),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(230, 110, 0, 0),
child: ElevatedButton(
onPressed: () {},
child: const Text(
"Add to Cart ",
),
style: ElevatedButton.styleFrom(
primary: Colors.pinkAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
bottomRight: Radius.circular(20),
),
),
padding: const EdgeInsets.all(28),
),
),
),
],
),
],
),
);
}
}
home_page.dart
import 'package:flutter/material.dart';
import 'package:fashion_app/details_screen.dart';
import 'package:flutter/services.dart';
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
//final double _borderRadious = 24;
#override
#override
void initState() {
// TODO: implement initState
super.initState();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.pinkAccent,
),
body: ListView(
padding: const EdgeInsets.only(top: 40, left: 20, right: 20),
children: [
HelloText(),
Name(),
SizedBox(
height: 10,
),
buildSearchInput(),
SizedBox(
height: 10,
),
Stack(children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 45, 10, 0),
child: TextButton(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.red.shade50,
),
height: 137,
width: 327,
child: Column(
children: const [
Padding(
padding: const EdgeInsets.fromLTRB(20, 40, 100, 40),
child: Text(
"Summer Collections",
style: TextStyle(
fontSize: 24,
color: Color(0xff262626),
fontWeight: FontWeight.w700),
textAlign: TextAlign.justify,
),
),
],
)),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DetailsScreen()));
},
),
),
const Padding(
padding: EdgeInsets.fromLTRB(200, 0, 10, 0),
child: Image(
image: AssetImage("assets/images/dressone.png"),
),
),
]),
Stack(children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 45, 10, 0),
child: TextButton(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.red.shade50,
),
height: 137,
width: 327,
child: Column(
children: const [
Padding(
padding: const EdgeInsets.fromLTRB(20, 40, 100, 40),
child: Text(
"Winter Collections",
style: TextStyle(
fontSize: 24,
color: Color(0xff262626),
fontWeight: FontWeight.w700),
textAlign: TextAlign.justify,
),
),
],
)),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DetailsScreen()));
},
),
),
const Padding(
padding: EdgeInsets.fromLTRB(200, 0, 10, 0),
child: Image(
image: AssetImage("assets/images/dresstwo.png"),
),
),
]),
Stack(children: [
Padding(
padding: const EdgeInsets.fromLTRB(5, 20, 10, 0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.blue.shade50,
),
height: 137,
width: 327,
child: Row(
children: const [
Padding(
padding: EdgeInsets.fromLTRB(150, 40, 0, 40),
child: Text(
"Get",
style: TextStyle(
fontSize: 24,
color: Colors.black,
fontWeight: FontWeight.w700),
),
),
Padding(
padding: EdgeInsets.all(5.0),
child: Text(
"30%",
style: TextStyle(
fontSize: 24,
color: Colors.purple,
fontWeight: FontWeight.w700),
),
),
Text(
"Off",
style: TextStyle(
fontSize: 24,
color: Colors.black,
fontWeight: FontWeight.w700),
),
],
)),
),
const Padding(
padding: EdgeInsets.fromLTRB(15, 0, 10, 0),
child: Image(
image: AssetImage("assets/images/dressthree.png"),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(230, 110, 0, 40),
child: ElevatedButton(
onPressed: () {},
child: const Text(
"Know More",
),
style: ElevatedButton.styleFrom(
primary: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
bottomRight: Radius.circular(20))),
padding: const EdgeInsets.all(15)),
),
),
]),
],
),
);
}
Widget HelloText() => Container(
child: Row(children: [
Text(
'Hello,',
style: TextStyle(
fontSize: 28,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
]),
);
Widget Name() => Container(
child: Row(children: [
Text(
'Nirasha',
style: TextStyle(
fontSize: 28,
color: Colors.amber,
fontWeight: FontWeight.w500,
),
),
]),
);
Widget buildSearchInput() => Container(
decoration: BoxDecoration(
color: Colors.grey[300], borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: Row(
children: [
Icon(
Icons.search,
size: 30,
color: Colors.grey,
),
Flexible(
child: TextField(
decoration: InputDecoration(border: InputBorder.none),
),
),
],
),
),
);
}
use following Structure in detail_screen.dart scaffold:
body : SafeArea(
child: Column(
children: <Widget>[
Container(child: IconButton(
icon: Icon(
Icons.chevron_left_sharp, //backIcon
color: Colors.indigo,
size: 30,
),
onPressed: () {
Navigator.pop(context);
},
),
-------------------- //other Elements Of body
]
),
)
Please use this : Navigator.of(context).pop();
In your detail_screen.dart, use this code in Appbar leading.
IconButton(
icon: new Icon(
Icons.arrow_back_rounded,
color: Colors.black,
),
onPressed: () => Navigator.pop(context),
),
Used this code now it is working.
leading: IconButton(
icon: new Icon(
Icons.arrow_back_rounded,
color: Colors.black,
),
onPressed: () {Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomePage()));
},
),
In your DetailScreen, your leading widget should be IconButton and handle onpressed event of that IconButton to pop the activity from stack.
Here it is:
leading: IconButton(
icon: new Icon(
Icons.arrow_back_rounded,
color: Colors.black,
),
onPressed: () => Navigator.pop(context),
),

How to fade text when text is overflowed?

I'm having a problem with handling texts when they overflow. I've tried overflow: TextOverflow.xxxx ,Expanded and Flexible but it's still doesn't work. Can anyone help me with this situation?
class _FeaturedCardState extends State<FeaturedCard>{
#override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
showToast(widget.name, context);
},
child: Padding(
padding: EdgeInsets.only(top: 5.0),
child: Container(
height: MediaQuery.of(context).size.height / 9,
width: MediaQuery.of(context).size.width,
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
elevation: 3.0,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(5.0),
child: CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
),
SizedBox(width: 10),
Padding(
padding: EdgeInsets.fromLTRB(0.0, 3.0, 3.0, 3.0),
child: Wrap(
direction: Axis.vertical,
children: <Widget>[
SizedBox(height: 2),
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
SizedBox(height: 3),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.attach_money,
size: 11,
),
Text(
widget.salary,
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300]
),
)
],
),
SizedBox(height: 3),
Text( // This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
I've searched a lot of atricles and it still doesn't help. If anyone could come up with a solution for this that'll be really great. Any help would be appreciated, thank you.
You can try this,
class _FeaturedCardState extends State<FeaturedCard> {
#override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
elevation: 3.0,
child: InkWell(
borderRadius: BorderRadius.circular(5.0),
onTap: (){
showToast(widget.name, context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
const SizedBox(height: 3),
Text(
"\u0024${widget.salary}", // Char code for $ symbol "\u0024"
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300],
),
),
const SizedBox(height: 3),
Text(
// This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
}
Add your Text in Container and set static width for Container
for example:
Container(
width: MediaQuery.of(context).size.width*0.7,
child: Text( "xxxxx",),
),

Error while running flutter app

This is the error message which I am getting:
Please do look at it below is my code:
void main(){
runApp(HomePage());
}
class HomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/dotbg.jpg"),
fit: BoxFit.cover,
),
),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'Welcome!',
style: TextStyle(
fontSize: 30.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
Container(height: 10.0),
RaisedButton(
padding: EdgeInsets.symmetric(
horizontal: 50.0, vertical: 15.0),
textColor: Colors.black,
child: Text(
'Play Online',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
onPressed: () {
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0))),
Container(
height: 30.0,
),
RaisedButton(
padding: EdgeInsets.symmetric(
horizontal: 50.0, vertical: 15.0),
textColor: Colors.black,
child: Text(
'Play Offline',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder:(context)=> OfflinePage()),);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0))),
Container(height: 70.0),
Text(
'Copyright#2019 DotsNBoxes',
style: TextStyle(fontSize: 20.0),
),
],
),
)
],
)),
);
}
}
This problem is solved by adding MaterialApp :
void main()
runApp(
MaterialApp(home: HomePage()),
);
}