Pass snapshot data to Flutter Widget - flutter

I am trying to pass from data from snapshot through to a Widget so I can render out the data but I am getting the following error
lib/screens/RetailerList.dart:215:35: Error: Too few positional arguments: 1 required, 0 given.
? _buildRetailer(retailer: snapshot.data)
Widgets
Widget _buildRetailer(Retailer retailer) {
return GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
// builder: (_) => RetailerDetails(retailer: retailer[0]),
),
);
},
child: Padding(
padding: EdgeInsets.only(left: 40.0, bottom: 30.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Hero(
tag: retailer.slug,
child: Container(
width: double.infinity,
height: 250.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
bottomLeft: Radius.circular(20.0),
),
image: DecorationImage(
image: NetworkImage(
"https://site-assets.afterpay.com/assets/favicon/apple-touch-icon-47062a004c5b1440ea8159b43580154540d76df61dc55dc87522378f8f76bbec.png",
),
fit: BoxFit.cover,
),
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(12.0, 12.0, 40.0, 0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
retailer.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
IconButton(
icon: Icon(Icons.favorite_border),
iconSize: 30.0,
color: Color(0xFFFD6456),
onPressed: () => print('Favorite'),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(12.0, 0.0, 40.0, 12.0),
child: Text(
retailer.shortDescription,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16.0,
color: Colors.grey,
),
),
),
],
),
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: Theme.of(context).platform == TargetPlatform.iOS
? CupertinoNavigationBar(
actionsForegroundColor: Color.fromRGBO(108, 212, 196, 1),
middle: Text('Explore Retailers',
style: GoogleFonts.nunito(
fontWeight: FontWeight.w700,
textStyle: TextStyle(
color: Color.fromRGBO(98, 49, 158, 1),
letterSpacing: .5,
fontSize: 20))),
leading: IconButton(
tooltip: 'Filter Retailers',
icon: Icon(IconData(0xF4A6,
fontFamily: CupertinoIcons.iconFont,
fontPackage: CupertinoIcons.iconFontPackage)),
// onPressed: _onButtonPressed
),
)
: AppBar(
title: Text('Explore Retailers',
style: GoogleFonts.nunito(fontWeight: FontWeight.w700)),
actions: <Widget>[
IconButton(
tooltip: 'Filter Retailers',
icon: Icon(Icons.filter_list),
// onPressed: _onButtonPressed
)
],
),
backgroundColor: Colors.white,
body: ListView(
children: <Widget>[
SizedBox(height: 10.0),
Container(height: 100.0, child: _buildListView()),
SizedBox(height: 50.0),
StreamBuilder<List<Retailer>>(
stream: fetchRetailers().asStream(),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? _buildRetailer(retailer: snapshot.data)
: Center(child: CircularProgressIndicator());
},
)
],
),
);
}
}

Instead of buildRetailer(retailer: snapshot.data)
Do buildRetailer(snapshot.data)
Since you're passing the data to the named parameter retailer which doesn't exist, as you have defined positional parameter in your buildRetailer method

Related

Flutter: I would like to scroll the ListView after the main SingleChildScrollView Scroll end

I have a ListView.builder wrapped with a SingleChildScrollView, and each has its scroll, so when I click at the ListView it only scroll the ListView without Scroll the SingleChildScrollView, and my ListView is dynamic so I can't use physics: const NeverScrollableScrollPhysics() because it disable my ListVeiw.builder
I want to Scroll the main screen which has some widgets and the ListView, builder in the middle and in last has a bottom
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Carrinho",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 18,
fontFamily: 'Inter'),
),
),
body: SingleChildScrollView(
child: Column(
children: [
Stack(
children: <Widget>[
Container(
width: 400,
child: Image.asset('assets/images/cover.jpg'),
),
Center(
child: Column(
children: [
SizedBox(height: 60),
Text(
"MEU CESTO",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 30,
fontFamily: 'Inter'),
),
],
),
),
],
),
Container(
height: 80,
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
color: sGreenColour,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
child: Container(
child: Column(
children: [
Row(children: [
Text(
"ITENS: ",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 16),
),
Text("$itemsQtd",
style: TextStyle(color: Colors.white, fontSize: 16))
]),
Row(children: [
Text("TOTAL: ",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 18)),
Text("$totalValue MT",
style: TextStyle(color: Colors.white, fontSize: 18))
])
],
),
),
),
Container(
height: MediaQuery.of(context).size.height,
// HERE MY ListView.buider
child: CartProducts(
cart_list: cart_list,
),
),
SizedBox(height: 40),
Container(
width: MediaQuery.of(context).size.width - 30,
child: Row(
children: [
Container(
height: 50,
width: (MediaQuery.of(context).size.width / 2) - 15,
child: ElevatedButton(
onPressed: () {},
child: Text("$totalValue MT",
style: TextStyle(color: sGreenColour)),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
sGreenLightColour),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
),
),
Container(
height: 50,
width: (MediaQuery.of(context).size.width / 2) - 15,
child: ElevatedButton(
onPressed: () {},
child: Text(
"TERMINAR",
style: TextStyle(color: Colors.white),
),
style: ButtonStyle(
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
side: BorderSide(color: sGreenColour),
),
),
),
),
)
],
),
),
SizedBox(height: 10),
],
),
));
}
}
and my ListView.builder
class _CartProductsState extends State<CartProducts> {
#override
Widget build(BuildContext context) {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), // Disable Scroll
itemCount: widget.cart_list.length,
itemBuilder: (BuildContext context, int index) {
return SigleProduct(
name: widget.cart_list[index]["name"],
picture: widget.cart_list[index]["picture"],
price: widget.cart_list[index]["price"],
unit: widget.cart_list[index]["unit"],
);
});
}
}
// THE ELEMENT OF THE GRIDVIEW
class SigleProduct extends StatelessWidget {
SigleProduct({this.name, this.picture, this.price, this.unit})
: super(key: null);
final name;
final picture;
final price;
final unit;
showAlertDialog(BuildContext context, int id) {
// set up the buttons
Widget cancelButton = TextButton(
child: Text("Não"),
onPressed: () {
Navigator.of(context).pop(); // dismiss dialog
},
);
Widget continueButton = TextButton(
child: Text(
"Sim",
style: TextStyle(color: Colors.red),
),
onPressed: () {
Navigator.of(context).pop(); // dismiss dialog
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Producto Removido!"),
));
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Center(child: Text("Alerta!")),
content: Text("Gostaria de Remover o producto do carrinho?"),
actions: [
cancelButton,
continueButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
#override
Widget build(BuildContext context) {
return Container(
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
child: ListTile(
onTap: () {},
leading: Container(
width: 80,
//color: Colors.amber,
child: Image.asset(picture),
),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(name,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 14)),
Text("$price MT",
style: TextStyle(
fontWeight: FontWeight.bold,
color: sGreenColour,
fontSize: 14)),
],
),
subtitle: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Unit: $price MT/$unit',
style: TextStyle(color: Colors.black45)),
Text('Qtd: 2/$unit', style: TextStyle(color: Colors.black45)),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
height: 25,
width: 110,
child: ElevatedButton(
onPressed: () {
showAlertDialog(context, 1);
},
child: Text(
"REMOVER",
style: TextStyle(fontSize: 10, color: Colors.white),
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.red)),
),
),
Container(
height: 25,
width: 110,
child: ElevatedButton(
onPressed: () {},
child: Text("ACTUALIZAR",
style:
TextStyle(fontSize: 10, color: Colors.white))),
),
],
)
],
),
selected: false,
),
),
);
}
}
Please Help

Flutterflow RUN and TEST White screen - but shows top bar

I ve been following the exact steps from https://www.youtube.com/watch?v=YjweeM_Bt00
However, when I want to test it in either test or run, it loads only the top bar.
The rest is only white screen.
The preview mode opens correctly but of course doesn't show any data from firebase.
I suspect there is a problem with that but I triple checked every step in there and I just don't know what else to do.
Below is code for home page. any page loads with same problem
Thanks for the help.
import '../backend/backend.dart';
import '../drill_details/drill_details_widget.dart';
import '../flutter_flow/flutter_flow_theme.dart';
import '../flutter_flow/flutter_flow_util.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class HomePageWidget extends StatefulWidget {
const HomePageWidget({Key? key}) : super(key: key);
#override
_HomePageWidgetState createState() => _HomePageWidgetState();
}
class _HomePageWidgetState extends State<HomePageWidget> {
final scaffoldKey = GlobalKey<ScaffoldState>();
#override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
appBar: AppBar(
backgroundColor: FlutterFlowTheme.of(context).primaryColor,
automaticallyImplyLeading: false,
title: Text(
'Drills',
style: FlutterFlowTheme.of(context).title2.override(
fontFamily: 'Poppins',
color: Colors.white,
fontSize: 22,
),
),
actions: [],
centerTitle: false,
elevation: 2,
),
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
StreamBuilder<List<DrillsRecord>>(
stream: queryDrillsRecord(),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
width: 50,
height: 50,
child: CircularProgressIndicator(
color: FlutterFlowTheme.of(context).primaryColor,
),
),
);
}
List<DrillsRecord> listViewDrillsRecordList =
snapshot.data!;
return ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: listViewDrillsRecordList.length,
itemBuilder: (context, listViewIndex) {
final listViewDrillsRecord =
listViewDrillsRecordList[listViewIndex];
return Padding(
padding:
EdgeInsetsDirectional.fromSTEB(16, 12, 16, 12),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
blurRadius: 3,
color: Color(0x3D0F1113),
offset: Offset(0, 1),
)
],
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Stack(
children: [
InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DrillDetailsWidget(
docRef: listViewDrillsRecord
.reference,
),
),
);
},
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0),
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
child: Image.network(
'https://cdn.dribbble.com/users/5862142/screenshots/18341547/media/4d62994067420d9a295d8f120b4ed097.jpg?compress=1&resize=1200x900&vertical=top',
width: double.infinity,
height: 200,
fit: BoxFit.cover,
),
),
),
Align(
alignment: AlignmentDirectional(1, -1),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 16, 16, 0),
child: InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DrillDetailsWidget(
docRef: listViewDrillsRecord
.reference,
),
),
);
},
child: Container(
width: 70,
height: 32,
decoration: BoxDecoration(
color: Color(0xFF39D2C0),
borderRadius:
BorderRadius.circular(12),
),
alignment:
AlignmentDirectional(0, 0),
child: Padding(
padding: EdgeInsetsDirectional
.fromSTEB(16, 0, 16, 0),
child: Text(
'Open',
style:
FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'Outfit',
color: Colors.white,
fontSize: 14,
fontWeight:
FontWeight.normal,
),
),
),
),
),
),
),
],
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
12, 12, 12, 4),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
listViewDrillsRecord.drillTitle!,
style: FlutterFlowTheme.of(context)
.title3
.override(
fontFamily: 'Outfit',
color: Color(0xFF101213),
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
12, 0, 12, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Text(
listViewDrillsRecord.coach!,
style: FlutterFlowTheme.of(context)
.bodyText2
.override(
fontFamily: 'Outfit',
color: Color(0xFF57636C),
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
),
],
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
12, 0, 12, 12),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.star_rounded,
color: Color(0xFFEE8B60),
size: 24,
),
Text(
'4.5',
style: FlutterFlowTheme.of(context)
.bodyText2
.override(
fontFamily: 'Outfit',
color: Color(0xFF57636C),
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
],
),
Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
listViewDrillsRecord.price!
.toString(),
style: FlutterFlowTheme.of(context)
.title3
.override(
fontFamily: 'Outfit',
color: Color(0xFF101213),
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
Text(
listViewDrillsRecord
.specialtySport!,
style: FlutterFlowTheme.of(context)
.bodyText2
.override(
fontFamily: 'Outfit',
color: Color(0xFF57636C),
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
],
),
],
),
),
],
),
),
);
},
);
},
),
],
),
),
),
),
);
}
}
'''

StateError was thrown building StreamBuilder<DocumentSnapshot<Object?>Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist

I am Trying to build an app. which fetching the user credential data and shows in profile page. I am getting an error => Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist in the profile section need help
Widget headerProfile(BuildContext context, DocumentSnapshot snapshot) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.25,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
height: 200.0,
width: 180.0,
child: Column(
children: [
GestureDetector(
onTap: () {},
child: CircleAvatar(
backgroundColor: constantColors.transperant,
radius: 60.0,
backgroundImage: NetworkImage(snapshot['userimage']),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(snapshot['username'],
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 16.0)),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(EvaIcons.email, color: constantColors.greenColor),
Padding(
padding: const EdgeInsets.only(left:9.0),
child: Text(snapshot['useremail'],
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 13.0)),
),
],
),
),
],
),
),
),
Container(
// width: 200.0,
width: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top:16.0, right: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Followers',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Following',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top:16.0),
child: Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Posts',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
),
],
),
)
],
),
);
}
I think the error is coming from the snapshot['username'], snapshot['userimage'] and snapshot['useremail'].....
This is my Profile.dart
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
leading: IconButton(
onPressed: () {},
icon: Icon(
EvaIcons.settings2Outline,
color: constantColors.lightBlueColor,
)),
actions: [
IconButton(
onPressed: () {},
icon: Icon(EvaIcons.logOutOutline,
color: constantColors.greenColor)),
],
backgroundColor: constantColors.blueGreyColor.withOpacity(0.4),
title: RichText(
text: TextSpan(
text: 'My ',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
children: <TextSpan>[
TextSpan(
text: 'Profile',
style: TextStyle(
color: constantColors.blueColor,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
])),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: StreamBuilder<DocumentSnapshot>(
stream: FirebaseFirestore.instance
.collection('users')
.doc(Provider.of<Authentication>(context, listen: false)
.getUserUid)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else {
return new Column(
children: [
Provider.of<ProfileHelpers>(context, listen: false).headerProfile(context, snapshot.data)
],
);
}
},
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
color: constantColors.blueGreyColor.withOpacity(0.6)),
),
),
),
);
}
and below is the FirebaseOperations.dart
Future initUserData(BuildContext context) async {
return FirebaseFirestore.instance
.collection('users')
.doc(Provider.of<Authentication>(context, listen: false).getUserUid)
.get()
.then((doc) {
print('Fetching user data...');
initUserName = doc.data()['username'];
initUserEmail = doc.data()['useremail'];
initUserImage = doc.data()['userimage'];
print(initUserName);
print(initUserEmail);
print(initUserImage);
notifyListeners();
});
String initUserEmail, initUserName, initUserImage;
String get getInitUserName => initUserName;
String get getInitUserEmail => initUserEmail;
String get getInitUserImage => initUserImage;
All my code is this please help and there is user profile circle avatar at the bottom navbar it is also not the the image
Widget bottomNavBar(BuildContext context, int index, PageController pageController) {
return CustomNavigationBar(
currentIndex: index,
bubbleCurve: Curves.bounceIn,
scaleCurve: Curves.decelerate,
selectedColor: constantColors.blueColor,
unSelectedColor: constantColors.whiteColor,
strokeColor: constantColors.blueColor,
scaleFactor: 0.5,
iconSize: 30.0,
onTap: (val) {
index = val;
pageController.jumpToPage(val);
notifyListeners();
},
backgroundColor: Color(0xff040307),
items: [
CustomNavigationBarItem(icon: Icon(EvaIcons.home)),
CustomNavigationBarItem(icon: Icon(Icons.message_rounded)),
CustomNavigationBarItem(
icon: CircleAvatar(
radius: 35.0,
backgroundColor: constantColors.blueGreyColor,
backgroundImage: NetworkImage(Provider.of<FirebaseOperations>(context, listen: false).initUserImage),
)),
]);
}
Homepage.dart
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: constantColors.darkColor,
body: PageView(
controller: homepageController,
children: [
Feed(),
Chatroom(),
Profile(),
],
physics: NeverScrollableScrollPhysics(),
onPageChanged: (page) {
setState(() {
pageIndex = page;
});
},
),
bottomNavigationBar: Provider.of<HomepageHelpers>(context, listen: false)
.bottomNavBar(context, pageIndex, homepageController),
);
}
Please Help

Flutter: Listview is scrolling on iOS but not on Android

Custom Widget Listview is scrolling properly on iOS devices but not on Andriod devices. I checked on multiple devices, the same result. I'm using the same widget in BottomSheet it works just fine on both platforms. I couldn't figure out what is the issue.
The following is the code:
UI Screen
class OnBoardingScreen extends StatelessWidget {
//
final _dataAssetController = Get.find<DataAsset>();
#override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('images/ss.jpg'),
),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.only(left: 15.0, top: 25.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
///---------------------- Title
Text(
'Your',
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Text(
'Star Sign?',
style: TextStyle(
fontSize: 45.0,
fontFamily: 'FredokaOne',
letterSpacing: 2.0,
color: _dataAssetController.mainColor,
),
),
SizedBox(height: 15.0),
///---------------------- Zodiac List
ZodiacListWidget(),
],
),
),
),
),
),
);
}
}
Listview Widget
class ZodiacListWidget extends StatelessWidget {
//
final _dataAssetController = Get.find<DataAsset>();
//
final _zodiacController = Get.find<ZodiacApiController>();
#override
Widget build(BuildContext context) {
return Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: _dataAssetController.zodiacList.length,
itemBuilder: (BuildContext context, index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Card(
color: Colors.grey[800],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: ListTile(
title: Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text(
_dataAssetController.zodiacList[index],
style: TextStyle(
color: Colors.grey[100],
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
),
subtitle: Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text(
_dataAssetController.zodiacDateRangeList[index],
style: TextStyle(
color: Colors.grey[500],
fontSize: 18.0,
),
),
),
leading: CircleAvatar(
radius: 20.0,
backgroundColor: Colors.grey[800],
child: SvgPicture.asset(
_dataAssetController.zodiacSVGList[index],
color: _dataAssetController.mainColor,
),
),
trailing: IconButton(
icon: GetBuilder<ZodiacApiController>(
builder: (_zController) => Icon(
Icons.adjust,
size: 25.0,
color: _dataAssetController.zodiacList[index] ==
_zController.zodiacSign
? _dataAssetController.mainColor
: Colors.grey[300],
),
),
onPressed: () {
_zodiacController.changeZodiac(index);
_zodiacController.onBoarding != null
? null
: Get.defaultDialog(
title: '',
titleStyle: TextStyle(
fontSize: 0.0,
),
middleText: _zodiacController.zodiacSign!,
middleTextStyle: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
textConfirm: 'Confirm',
confirmTextColor: Colors.white,
onConfirm: () {
_zodiacController.onBoarding != null
? null
: _zodiacController.changeOnBoarding();
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(),
),
);
},
textCancel: 'Back',
cancelTextColor: Colors.blueAccent,
onCancel: () => Navigator.pop(context),
);
},
),
),
),
);
},
),
);
}
}

Flutter wrap text inside nested Widgets

My Text widget is not wrapping, causing an overflow. I've tried methods from this post, but appear to be missing the right spot to add in a flex/expanded.
The spot where it says "//get this text to wrap" is the Text widget I'd like to wrap.
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(snapshot.data[index].message_text, //get this text to wrap
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.visible,
),
),
Full Code:
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(title: Text("Comments")),
body: Container(
child: Column(
children: <Widget>[
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
child: new RefreshIndicator(
child:
Container(
child: FutureBuilder(
future: getAllCommentsForAd(this.ad_id_passed_in),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.data == null) {
return Container(
child: Center(
child: Text("Loading..."),
)
);
} else {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
// return ListTile(
// leading: CircleAvatar(
// radius: 35.0,
// backgroundImage: new NetworkImage(snapshot.data[index].imageUrl),
// ),
// title: Text(snapshot.data[index].email),
// );
return GestureDetector(
onTap: () => (
print("tapped that")
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => MessageScreenRoom(
// snapshot.data[index],this.logged_in_user_id
// ),
// ),
// )
),
child: Container(
margin: EdgeInsets.only(
top: 5.0,
bottom: 5.0,
right: 1.0,
left: 10.0,
),
padding:
EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
decoration: BoxDecoration(
color: snapshot.data[index].hearted ? Colors.lime[50] : Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(20.0),
bottomRight: Radius.circular(20.0),
topLeft: Radius.circular(20.0),
bottomLeft: Radius.circular(20.0),
)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
CircleAvatar(
radius: 35.0,
backgroundImage: new NetworkImage(snapshot.data[index].imageUrl),
),
SizedBox(
width: 10.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(snapshot.data[index].user_name,
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
fontWeight: FontWeight.bold,
)),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(snapshot.data[index].message_text, //get this text to wrap
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
fontWeight: FontWeight.bold,
)),
),
SizedBox(
height: 10.0,
),
Container(
width: MediaQuery.of(context).size.width * 0.45,
child: Text(
"",
style: TextStyle(
color: Colors.blueGrey,
fontSize: 15.0,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
)
],
),
],
),
),
Column(
children: <Widget>[
Text("",
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
fontWeight: FontWeight.bold)),
SizedBox(
height: 5.0,
),
snapshot.data[index].hearted
? Container(
width: 40.0,
height: 20.0,
alignment: Alignment.center,
child: Icon(Icons.favorite, color: Colors.red, size: 30),
)
: Icon(Icons.favorite_border, color: Colors.red, size: 30),
],
),
],
),
),
);
},
);
}
}
),
),
onRefresh: refreshMessages,
),
),
),
),
// _buildMessageComposer(),
Row(
children: <Widget>[
Expanded(child: TextField(
textCapitalization: TextCapitalization.sentences,
controller: text_message_controller,
onChanged: (value){
},
decoration: InputDecoration.collapsed(hintText: ' Leave a comment...'),
)),
IconButton(
icon: Icon(Icons.send),
iconSize: 30.0,
color: Theme.of(context).primaryColor,
onPressed: () {
//send comment TODO: do this comment send
sendComment(ad_id_passed_in, this.logged_in_user_id, text_message_controller.text);
text_message_controller.clear();
setState(() {
});
})
],
),
],
),
),
);
}
try wrapping your text with Flexible widget