"'borderRadius != null I/flutter (28205): || clipper != null': is not true" why am i getting this error? - flutter

I am trying to fetch data from an api and just show it in my list of cards. But whenever i load the app i get this error
'borderRadius != null
I/flutter (28205): || clipper != null': is not true.
and i not sure how to solve this.
I have tried making changes in the line the error has occurred but the error remains the same.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:news/model/businessModel.dart';
import 'package:http/http.dart' as http;
class Discover extends StatefulWidget {
final Source source;
Discover({Key key, this.source}) : super(key: key);
#override
_DiscoverState createState() => _DiscoverState();
}
class _DiscoverState extends State<Discover> {
String API_KEY = '0ca85f22bce44565ba4fee8d2224adb5';
Future<List<Articles>> fetchArticleBySource() async {
final response = await http.get(
'https://newsapi.org/v2/top-headlines?
category=business&language=en&apiKey=${API_KEY}');
if (response.statusCode == 200) {
List articles = json.decode(response.body)['articles'];
return articles.map((article) => new
Articles.fromJson(article)).toList();
} else {
throw Exception('Failed to load article list');
}
}
var list_articles;
var refreshKey = GlobalKey<RefreshIndicatorState>();
#override
void initState() {
// TODO: implement initState
super.initState();
refreshListArticle();
}
Future<Null> refreshListArticle() async {
refreshKey.currentState?.show(atTop: false);
setState(() {
list_articles = fetchArticleBySource();
});
}
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
left: 15.0,
top: 15.0,
right: 15.0,
),
child: ListView(
children: <Widget>[
topArea(),
SizedBox(
height: 10.0,
),
slideCard(),
SizedBox(
height: 5.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Divider(),
),
recentNews(),
],
),
);
}
Widget topArea() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"WEDNESDAY, NOVEMBER 29",
style: TextStyle(color: Colors.grey, fontWeight:
FontWeight.bold),
),
SizedBox(
height: 5.0,
),
Text(
"TOP NEWS",
style: TextStyle(fontSize: 25.0, fontWeight: FontWeight.bold),
),
],
),
Hero(
tag: 'img',
child: InkWell(
//onTap: () => Navigator.push(context, MaterialPageRoute(builder:
(context) => )),
child: CircleAvatar(
radius: 25.0,
//backgroundColor: Colors.transparent,
backgroundImage: NetworkImage(
"https://images.pexels.com/photos/1138409/pexels-photo-
1138409.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
),
),
),
),
],
);
}
Widget slideCard() {
return FutureBuilder<List<Articles>>(
future: list_articles,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Text("${snapshot.error}");
} else if (snapshot.hasData) {
List<Articles> articles = snapshot.data;
return Container(
height: 310.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(0.0),
),
child: ListView(
scrollDirection: Axis.horizontal,
children: articles
.map((article) => GestureDetector(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: ClipRRect(
clipper: ,
child: article.urlToImage != null
? Image.network(article.urlToImage)
: Image.asset('images/logo.jpg'),
),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text("${article.title}",
style: TextStyle(
color: Colors.blueAccent,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"${article.description}",
style: TextStyle(
color: Colors.black,
fontSize: 14.0,
fontWeight: FontWeight.bold),
),
),
],
),
))
.toList(),
),
);
}
return CircularProgressIndicator();
},
);
}
Widget recentNews() {
return Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Recent News",
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
),
Align(
alignment: Alignment.centerRight,
child: Text(
"See All",
style: TextStyle(color: Colors.lightBlueAccent),
),
)
],
),
),
SizedBox(
height: 7.0,
),
Container(
height: 200.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: ClipRRect(
child: Image.network(
"https://images.pexels.com/photos/935789/pexels-photo-935789.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"),
borderRadius: BorderRadius.circular(10.0),
),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"STARTUPS",
style: TextStyle(
color: Colors.blueAccent,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Top startups that are \nchanging the way we travel",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold),
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: ClipRRect(
child: Image.network(
"https://images.pexels.com/photos/935789/pexels-photo-935789.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"),
borderRadius: BorderRadius.circular(10.0),
),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"STARTUPS",
style: TextStyle(
color: Colors.blueAccent,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Top startups that are \nchanging the way we travel",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold),
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: ClipRRect(
child: Image.network(
"https://images.pexels.com/photos/935789/pexels-photo-935789.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"),
borderRadius: BorderRadius.circular(10.0),
),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"STARTUPS",
style: TextStyle(
color: Colors.blueAccent,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Top startups that are \nchanging the way we travel",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold),
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: ClipRRect(
child: Image.network(
"https://images.pexels.com/photos/935789/pexels-photo-935789.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"),
borderRadius: BorderRadius.circular(10.0),
),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"STARTUPS",
style: TextStyle(
color: Colors.blueAccent,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Top startups that are\n changing the way we travel",
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold),
),
),
],
),
],
),
),
],
);
}
}

If you look closely, you will see one ClipRRect whose clipper is empty, thus null.
According to the error message, if the clipper is null, then you have to specify a borderRadius.
child: ClipRRect(
clipper: ,
child: article.urlToImage != null
? Image.network(article.urlToImage)
: Image.asset('images/logo.jpg'),
),

Related

How to organize widgets on flutter?

This is my problem:
I want to achieve this design, like this:
This is my code:
#override
Widget build(BuildContext context) {
return BackdropFilter(
filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: ClipRRect(
//<---here
borderRadius: BorderRadius.circular(10),
child: Container(
height: MediaQuery.of(context).size.height,
width: 600,
decoration: const BoxDecoration(
color: Color(0xffF6F6F6),
),
child: LayoutBuilder(
builder: (context, constraints) => Stack(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
Icon(FontAwesomeIcons.checkDouble,
size: 40, color: Color(0xffD6D6D6)),
Icon(FontAwesomeIcons.squareXmark,
size: 40, color: Color(0xff404040)),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(15, 60, 15, 0),
child: Stack(
children: [
Center(
child: Text(
"We send you an Email",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Divider(color: Color(0xff3B3B3B)),
),
Text(
"Please, check your Email inbox to log in and start using Pomoworko",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Divider(color: Color(0xff3B3B3B)),
),
],
),
),
RiveAnimation.asset(
"img/letter_and_knife.riv",
),
],
),
),
),
),
),
),
),
);
}
I get stuck on this, I used a column, but don't work, and I don't know how to organize the widgets, what widget may be helpful to use in order to achieve the second design?
The pink color is: color: Color(0xffF4CFDD)
Thanks for considering my request.
You are using wrong widget, instead of stack, you need to use column like this:
BackdropFilter(
filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
height: MediaQuery.of(context).size.height,
width: 600,
decoration: const BoxDecoration(
color: Color(0xffF6F6F6),
),
child: LayoutBuilder(
builder: (context, constraints) => Column(
children: [
Container(
color: Colors.white,
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: const [
Icon(Icons.check,
size: 40, color: Color(0xffD6D6D6)),
Icon(Icons.close,
size: 40, color: Color(0xff404040)),
],
),
),
Padding(
padding:
const EdgeInsets.fromLTRB(15, 60, 15, 0),
child: Column(
children: [
Center(
child: Text(
"We send you an Email",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
),
Padding(
padding:
EdgeInsets.symmetric(vertical: 8.0),
child: Divider(color: Color(0xff3B3B3B)),
),
Text(
"Please, check your Email inbox to log in and start using Pomoworko",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
Padding(
padding:
EdgeInsets.symmetric(vertical: 8.0),
child: Divider(color: Color(0xff3B3B3B)),
),
],
),
),
Container(
color: Colors.red,
width: 100,
height: 100,
),
],
),
),
),
),
),
),
),
)

Flutter comment_tree 0.3.0 How to remove replies under comments

I use the component as in the description, I can’t figure out how to remove the answer (child component) in the component itself, or at least how to check if it exists, then show it, if not, then don’t show it.
https://gist.github.com/lomanu4/3abba49f6fbcecbde4c07df82c3ce11c
class _ComentCardState extends State<ComentCard> {
bool childcomment = false;
#override
Widget build(BuildContext context) {
return Column(children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: CommentTreeWidget<Comment, Comment?>(
Comment(
avatar: 'null',
userName: widget.snap['name'],
content: '${widget.snap['text']} '),
[
Comment(avatar: 'null', userName: 'null', content: 'null'),
],
treeThemeData: childcomment
? TreeThemeData(lineColor: Colors.green[500]!, lineWidth: 3)
: TreeThemeData(lineColor: Colors.green[500]!, lineWidth: 3),
avatarRoot: (context, data) => PreferredSize(
preferredSize: const Size.fromRadius(18),
child: Row(
children: [
CircleAvatar(
radius: 18,
backgroundColor: Colors.grey,
backgroundImage:
NetworkImage(widget.snap['profilePic'].toString()),
),
],
),
),
avatarChild: (context, data) => const PreferredSize(
preferredSize: Size.fromRadius(12),
child: CircleAvatar(
radius: 12,
backgroundColor: Colors.grey,
backgroundImage: AssetImage('lib/assets/homescreen.png'),
),
),
contentChild: (context, data) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'dangngocduc',
style: Theme.of(context).textTheme.caption?.copyWith(
fontWeight: FontWeight.w600, color: Colors.black),
),
const SizedBox(
height: 4,
),
Text(
'${data!.content}',
style: Theme.of(context).textTheme.caption?.copyWith(
fontWeight: FontWeight.w300, color: Colors.black),
),
],
),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.caption!.copyWith(
color: Colors.grey[700], fontWeight: FontWeight.bold),
child: Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
children: const [
SizedBox(
width: 8,
),
Text('Reply'),
],
),
),
)
],
);
},
contentRoot: (context, data) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.snap['name'],
style: Theme.of(context).textTheme.caption!.copyWith(
fontWeight: FontWeight.w600, color: Colors.black),
),
const SizedBox(
height: 4,
),
Text(
'${data.content}',
style: Theme.of(context).textTheme.caption!.copyWith(
fontWeight: FontWeight.w300, color: Colors.black),
),
const SizedBox(
height: 4,
),
],
),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.caption!.copyWith(
color: Colors.grey[700], fontWeight: FontWeight.bold),
child: Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
children: [
SizedBox(
width: 8,
),
Text('Like'),
SizedBox(
width: 24,
),
Expanded(child: Text('Reply')),
Container(
padding: const EdgeInsets.all(8),
child: const Icon(
Icons.favorite_border,
size: 16,
),
)
],
),
),
),
],
);
},
),
),
]);
}

how to display bottom navbar without scrolling down

In my flutter code, I have created a separate navbar widget and called it on my page. I have used a single-child scroll view. now I have to scroll the page to see the navbar. I want it to be appeared bottom top of the page. how can I do this? the image shows when I scroll down how the nav bar appears. appreciate your help on this.
class ProfessionalProfile extends StatefulWidget {
const ProfessionalProfile({Key? key}) : super(key: key);
#override
State<ProfessionalProfile> createState() => _ProfessionalProfileState();
}
class _ProfessionalProfileState extends State<ProfessionalProfile> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
iconTheme: IconThemeData(color: Colors.black),
),
drawer: HiddenDrawer(),
body: SingleChildScrollView(
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: Colors.lightBlue,
image: new DecorationImage(
image: new ExactAssetImage(
'assets/images/user.png'
),
fit: BoxFit.cover,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Text(
'Nirosha Kumuduni',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Text(
'neo#gmail.com',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/briefcase.png',
),
),
),
new Text(
'Profession',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' Interior Designer',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/home.png',
),
),
),
new Text(
'Address',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' 25/A, Horton Place, Colombo',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/phone-call.png',
),
),
),
new Text(
'Mobile Number',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:180,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' +94 771122334',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/mail.png',
),
),
),
new Text(
'Email Address',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:180,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' neo#gmail.com',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/hand-shake.png',
),
),
),
new Text(
'Business Name',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:170,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' NEO GROUP',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/target.png',
),
),
),
new Text(
'Business Description',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 40,
width:320,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: MainGreen.withOpacity(.3),
),
child: new Text(
' 25/A, Horton Place, Colombo',
style: TextStyle(
fontSize: 15.0,
),
),
),
)
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
),
),
new Text(
'Ratings & Reviews',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
new Text(
'4.1',
style: TextStyle(
fontSize: 40.0,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 20,
width: 20,
child: Image.asset(
'assets/icons/rating.png',
),
),
),
],
),
SizedBox(
height: 10,
),
SizedBox(
height: 10,
),
Center(
child: GestureDetector(
child: MainButton("Edit Profile"),
// onTap: () async {
// FocusManager.instance.primaryFocus?.unfocus();
// if (_formKey.currentState!.validate()) {
// _formKey.currentState!.save();
// await LoginData();
// // Get.to(BottomNavigation());
// }
// },
onTap: (){
Get.to(DashboardScreen());
},
),
),
Container(
// width : MediaQuery.of(context).size.width,
height : 56,
child: BottomNavigation()
),
],
),
),
);
}
}
//bottom navigation
class BottomNavigation extends StatefulWidget {
const BottomNavigation({Key? key}) : super(key: key);
#override
State<BottomNavigation> createState() => _BottomNavigationState();
}
class _BottomNavigationState extends State<BottomNavigation> {
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Business',
),
BottomNavigationBarItem(
icon: Icon(Icons.star),
label: 'Reviews',
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.blue,
onTap: _onItemTapped,
),
],
),
);
}
}
you can do it like that
class _ProfessionalProfileState extends State<ProfessionalProfile> {
#override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigation() , // your BottomNavigation here
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
iconTheme: IconThemeData(color: Colors.black),
),
drawer: HiddenDrawer(),
body: SingleChildScrollView(
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [ ....

Flutter, how can I retrieve user info and display it on specific blog posts from firestore?

I'm new to dart and flutter comming from java(android). I have a list of posts, which are posted by different users. I want to display user name and user image for each post. The problem is I'm storing users in a "Users" collection and posts in a "Posts" collection. I have user id attached to each post and I can pull it(the id) together with the post details. But I can't use it(the id) to display profile info. Please help, some lines of code to give me some light will be much appreciated.
Bellow is my code to display the posts:
body: StreamBuilder(
stream: Firestore.instance.collection('Posts').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
const Text('Loading...');
} else {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot myPosts = snapshot.data.documents[index];
return Container(
width: MediaQuery.of(context).size.width,
//height: 350,
child: Padding(
padding: EdgeInsets.only(bottom: 8.0),
child: Center(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
children: <Widget>[
CircleAvatar(
radius: 20.0,
backgroundColor: Colors.blueGrey,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Container(
color: Colors.black45,
height: 30,
width: 2,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
'user name',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Colors.black54,
),
overflow: TextOverflow.ellipsis,
),
Text(
'user status',
style: TextStyle(
color: Colors.grey,
fontSize: 14.0,
),
)
],
),
)
],
),
SizedBox(
height: 10.0,
),
Container(
width: MediaQuery.of(context).size.width,
//height: 200.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: AspectRatio(
aspectRatio: 16 / 9,
child: FadeInImage.assetNetwork(
width: MediaQuery.of(context).size.width,
placeholder: 'assets/images/loading.jpg',
image: '${myPosts['post_image']}',
fit: BoxFit.fill,
),
),
),
),
SizedBox(
height: 10.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(
'${myPosts['post_title']}',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
FlatButton(
child: Text(
'Download Pdf',
style: TextStyle(
fontSize: 14.0,
color: Colors.black54,
),
),
shape: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black54, width: 1),
borderRadius: BorderRadius.circular(5),
),
padding: const EdgeInsets.fromLTRB(
15.0,
4.0,
15.0,
4.0,
),
onPressed: () {},
),
],
),
SizedBox(
height: 10.0,
),
Text(
'${myPosts['post_body']}',
style: TextStyle(
fontSize: 16.0,
),
overflow: TextOverflow.ellipsis,
maxLines: 8,
),
SizedBox(
height: 10.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Posted ' +
TimeAgo.getTimeAgo(
myPosts['post_time']),
style: TextStyle(color: Colors.grey)),
Text(
'${myPosts['comments_count']} Comment(s)',
style: TextStyle(color: Colors.grey)),
],
),
SizedBox(
height: 10.0,
),
],
),
),
),
),
);
},
);
}
return Loading();
},
),
Everything works fine, the problem is just to pull the user info. I have a class that I use to display user data on the profile page if it might be useful in this case here is the code of it below
import 'package:cloud_firestore/cloud_firestore.dart';
class ProfileService {
getProfileInfo(String uid) {
return Firestore.instance
.collection('Users')
.where('user_id', isEqualTo: uid)
.getDocuments();
}
}
Your help will be much appreciated I'm stuck.
try using this :
Future<DocumentSnapshot> _getDocument(String uid) async {
return await Firestore().collection('Users').where('user_id', isEqualTo: uid).get();
}
it will return u document snapshot which then u can use to get user information

ClipRRect not working properly using carousel inside listview(scrollview)

I am using a carousel from the package https://pub.dev/packages/carousel_slider, inside my listview (scrollview). I want to make my images have a round corner border.
I used clipRRect and it works (clip corner image with round border). But something strange happens to my apps. Here my result, I upload to google drive, please download first
https://drive.google.com/open?id=1YNRk3q87-wD080eNvLa9OQ1j2KytvaJW
And here my code
class HomeScreen extends StatelessWidget {
Widget menus(){
return Container(
margin: EdgeInsets.symmetric(horizontal: 21, vertical: 18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Layanan favorit',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
Text(
'Lihat Semua',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Color(0xFFFF2800)
),
),
],
),
Container(
margin: EdgeInsets.only(top: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconMenu(
text: 'Token Listrik',
image: SvgPicture.asset(ICON_ELECTRICITY),
),
IconMenu(
text: 'Pulsa',
image: SvgPicture.asset(ICON_BALANCE),
),
IconMenu(
text: 'Paket Data',
image: SvgPicture.asset(ICON_DATA),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 28),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconMenu(
text: 'Kereta Api',
image: SvgPicture.asset(ICON_TRAIN),
),
IconMenu(
text: 'e Money',
image: SvgPicture.asset(ICON_EMONEY),
),
IconMenu(
text: 'Pasca Bayar',
image: SvgPicture.asset(ICON_POSTPAID),
),
],
),
)
],
),
);
}
Widget offers(){
return Container(
margin: EdgeInsets.symmetric(vertical: 18),
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 21),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Hot offers',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
Text(
'Lihat Semua',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Color(0xFFFF2800)
),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 8),
child: CarouselOffers(),
)
],
),
);
}
#override
Widget build(BuildContext context) {
// TODO: implement build
return SafeArea(
child: Scaffold(
appBar: HomeAppBar(),
body: Container(
child: ListView(
children: <Widget>[
Card(
margin: EdgeInsets.fromLTRB(21, 21, 21, 18),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(20, 11, 20, 11),
decoration: BoxDecoration(
borderRadius: new BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
color: Theme.of(context).primaryColor
),
child: Row(
children: <Widget>[
Expanded(
child: Container(
child: Text(
'Kasku Balance',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w700
),
),
),
),
Container(
margin: EdgeInsets.only(right: 8),
child: Text(
'Rp 2.000.000',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w700
)
),
),
Container(
child: GestureDetector(
child: Icon(
Icons.refresh,
color: Colors.white,
),
),
),
],
),
),
Container(
padding: EdgeInsets.only(top: 16, bottom: 16),
decoration: BoxDecoration(
borderRadius: new BorderRadius.only(
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0)),
color: Colors.white
),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_TOPUP),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Isi Saldo',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
Container(
width: 1,
height: 54,
color: Color(0xFFD8D8D8),
),
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_PAY),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Bayar',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
Container(
width: 1,
height: 54,
color: Color(0xFFD8D8D8),
),
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_TRANSFER),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Transfer',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
],
),
),
],
),
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
menus(),
offers(),
news(),
news2()
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
title: Text('Jelajah'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Layanan'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Transaksi'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Profile'),
),
],
type: BottomNavigationBarType.fixed,
),
),
);
}
}
class CarouselOffers extends StatefulWidget{
#override
_CarouselOffersState createState() => _CarouselOffersState();
}
class _CarouselOffersState extends State<CarouselOffers> {
int _current = 0;
List<Widget> widgets(){
return ['https://cdn2.tstatic.net/lampung/foto/bank/images/bukalapak-promo-bulan-ramadan_20180511_135232.jpg', 'https://cdn2.tstatic.net/lampung/foto/bank/images/bukalapak-promo-bulan-ramadan_20180511_135232.jpg'].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
i,
fit: BoxFit.fill,
),
),
);
},
);
}).toList();
}
#override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
CarouselSlider(
pauseAutoPlayOnTouch: Duration(seconds: 3),
aspectRatio: 16/6,
items: widgets(),
onPageChanged: (index) {
setState(() {
_current = index;
});
},
autoPlay: true,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: map<Widget>(widgets(), (index, url) {
return Container(
width: 6.0,
height: 6.0,
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 4.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _current == index ? Theme.of(context).primaryColor : Color.fromRGBO(0, 0, 0, 0.4)
),
);
}),
)
],
);
}
}
what is wrong with my code? any ideas?
Sorry for late answer.
Everything is fine when using real device. I do not know why ClipperRRect not working properly when using emulator (Genymotion).