listview shows on emulator but not on actual phone - flutter

as typed above i am trying to display information using a listview but i noticed whenever i port this app to my phone via APK it just shows the background color nothing else! maybe im using expanded wrong or something i have no clue. this app works as intended on my emulator, the emulator im using is pixel 4 api 30
code home_page.dart
class _SummonerProfileRouteState extends State<SummonerProfileRoute> {
List<SummonerRank> SummonerRankList = <SummonerRank>[];
void getSummonerRankfromApi() async {
SummonerRankApi.getSummonerRank(summonerId).then((response) {
setState(() {
Iterable list = json.decode(response.body);
SummonerRankList =
list.map((model) => SummonerRank.fromJson(model)).toList();
});
});
}
String summonerName, summonerId;
int profileIconId, summonerLevel;
_SummonerProfileRouteState(this.summonerName, this.summonerId,
this.profileIconId, this.summonerLevel);
#override
void initState() {
super.initState();
getSummonerRankfromApi();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: customAppBar(),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
bgColorFront,
bgColorEnd,
],
),
),
child: ListView(
children: [
Expanded(
child: Column(
children: [
Padding(padding: EdgeInsets.only(top: 20)),
Text(
summonerName,
style: TextStyle(
fontSize: 35,
fontFamily: 'Spiegel',
fontWeight: FontWeight.bold,
),
),
Text(
"Level ${summonerLevel.toString()}",
style: TextStyle(
fontSize: 20,
color: customColorTextBlue,
),
),
Padding(padding: EdgeInsets.only(top: 10)),
Container(
width: 200,
height: 200,
child: AspectRatio(
aspectRatio: 1 / 1,
child: ClipOval(
child: FadeInImage.assetNetwork(
fit: BoxFit.cover,
placeholder: "images/placeholder.jpg",
image:
"https://ddragon.leagueoflegends.com/cdn/12.22.1/img/profileicon/$profileIconId.png"),
),
),
),
ListView(
shrinkWrap: true,
children: [
GridView.builder(
shrinkWrap: true,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
mainAxisSpacing: 20,
crossAxisSpacing: 20,
crossAxisCount: 2),
itemCount: SummonerRankList.length,
itemBuilder: (BuildContext ctx, index) {
return ListTile(
title: Text(
modeChecker(
SummonerRankList[index].queueType),
style: TextStyle(
fontFamily: 'Spiegel',
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${SummonerRankList[index].tier} ${SummonerRankList[index].rank}",
style: TextStyle(
color: customColorTextBlue,
fontSize: 18,
),
),
Text(
"${SummonerRankList[index].leaguePoints} LP",
style: TextStyle(
color: customColorTextBlue,
fontSize: 18,
),
),
Text(
"${calculateWinrate(SummonerRankList[index].wins, SummonerRankList[index].losses)}% Winrate",
style: TextStyle(
color: customColorTextBlue,
fontSize: 16,
),
),
],
));
}),
],
),
Container(
width: double.maxFinite,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
MyElevatedButton(
width: 350,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AllChampionsListedRoute(summonerId, summonerName)));
},
borderRadius: BorderRadius.circular(20),
child: Row(
children: [
Spacer(),
Icon(
Icons.call_made_sharp,
color: customColorTextBlue,
size: 26,
),
Padding(padding: EdgeInsets.only(right: 5)),
Text(
'Check champion statistics',
style: TextStyle(
color: customColorTextBlue,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
Spacer(),
],
),
),
],
),
),
],
),
),
],
),
));
}
}

Replace ListView with Column widget. You cant use Expanded inside ListView
return Scaffold(
appBar: customAppBar(),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
bgColorFront,
bgColorEnd,
],
),
),
child: Column( //this
children: [
Expanded(
child: Column(

Related

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,
),
),
],
),
],
),
),
],
),
),
);
},
);
},
),
],
),
),
),
),
);
}
}
'''

How to read Json from file and use it in this case

I am an absolute beginner in Flutter and want to build a timetable app. I don't get how I can use a local JSON file (including using Future if needed) to use it as data for the ListView (seperated).
I want to get the data of the lessons from the JSON file to display them in the app. Room, Time and teacher for every lesson.
Showing me how to implement it into my code would be great!
Any help and tip is much appreciated.
My code:
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'dart:async' show Future;
final List<String> entries = <String>['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Stundenplan",
home: DefaultTabController(
length: 5,
child: Scaffold(
appBar: AppBar(
bottom: const TabBar(
tabs: [
Tab(text: "Mo"),
Tab(text: "Di"),
Tab(text: "Mi"),
Tab(text: "Do"),
Tab(text: "Fr"),
],
),
title: const Text('Stundenplan'),
backgroundColor: Colors.blue,
),
body: TabBarView(
children: [
// MONDAY
Center(
child: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: mondayLessons.length,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Colors.red,
),
alignment: Alignment.center,
height: 150,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
/*2*/
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${index + 1} - ${jsonData["Montag"]}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 20,
),
),
),
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
times[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
mondayTeacher[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
Text(
mondayRooms[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),]
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
),
// TUESDAY
Center(
child: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: tuesdayLessons.length,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Colors.green,
),
alignment: Alignment.center,
height: 150,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
/*2*/
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${index + 1} - ${tuesdayLessons[index]}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 20,
),
),
),
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${times[index]} Uhr',
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
tuesdayTeacher[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
Text(
tuesdayRooms[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),]
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
),
// WEDNESDAY
Center(
child: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: wednesdayLessons.length,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Colors.yellow,
),
alignment: Alignment.center,
height: 150,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
/*2*/
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${index + 1} - ${wednesdayLessons[index]}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 20,
),
),
),
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
times[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
wednesdayTeacher[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
Text(
wednesdayRooms[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),]
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
),
// THURSDAY
Center(
child: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: thursdayLessons.length,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Colors.red,
),
alignment: Alignment.center,
height: 150,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
/*2*/
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${index + 1} - ${thursdayLessons[index]}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 20,
),
),
),
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${times[index]} Uhr',
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
thursdayTeacher[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
Text(
thursdayRooms[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),]
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
),
//FRIDAY
Center(
child: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: fridayLessons.length,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Colors.green,
),
alignment: Alignment.center,
height: 150,
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
/*2*/
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${index + 1} - ${fridayLessons[index]}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 20,
),
),
),
Container(
padding: const EdgeInsets.only(top: 0),
alignment: Alignment.topCenter,
child: Text(
'${times[index]} Uhr',
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
fridayTeacher[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),
Text(
fridayRooms[index],
style: const TextStyle(
color: Colors.black,
fontSize: 17.5,
),
),]
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
),
],
),
),
),
);
}
}
Keep the json file into your assets folder, then follow the below code:
String? data = await DefaultAssetBundle.of(context).loadString("assets/someData.json");
val jsonResult = jsonDecode(someData);
This code will be used to load json from the asset
Adding to this answer by Gourango, you can copy paste your json in https://app.quicktype.io/ , it will generate the classes you need to handle json more easily.
I am using this in my current project:
// load JSON
final String response =
await rootBundle.loadString('lib/assets/file.json');
final data = await json.decode(response);

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 : Release version create a problem

Where is the problem in my code ?
My app works fine in debug mode. But when I go to release mode, Some widgets don't show which placed in stack.
I took internet permission also. <uses-permission android:name="android.permission.INTERNET"/>
Here is my Debug version output that I want.
And here is my release version output
Here is my code -
import 'package:boimarket/model/model.dart';
import 'package:boimarket/screen/pdfscreen.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class BookDescription extends StatefulWidget {
BookDescription({Key key, #required this.storyBooksValue}) : super(key: key);
final storyBooksValue;
#override
_BookDescriptionState createState() => _BookDescriptionState();
}
class _BookDescriptionState extends State<BookDescription> {
#override
void initState() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp,
]);
super.initState();
}
#override
void dispose() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp,
]);
}
#override
Widget build(BuildContext context) {
var _boxHeight = MediaQuery.of(context).size.height;
var _boxWidth = MediaQuery.of(context).size.width;
final Color _whiteCream = Color.fromRGBO(250, 245, 228, .8);
final Color _darkBlue = Color.fromRGBO(0, 68, 69, 1);
final Color _lightBlue = Color.fromRGBO(44, 120, 108, 1);
return Scaffold(
appBar: null,
body: Stack(
children: <Widget>[
Container(
color: _lightBlue,
child: Stack(
children: <Widget>[
Card(
elevation: 10,
child: Container(
height: _boxHeight,
width: _boxWidth,
child: FadeInImage.assetNetwork(
fadeOutCurve: Curves.easeInCubic,
placeholder: 'assets/images/cover.jpg',
image: widget.storyBooksValue.imgUrl == null
? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
: widget.storyBooksValue.imgUrl,
height: _boxHeight,
width: _boxWidth,
fit: BoxFit.cover,
),
),
),
Container(
height: _boxHeight,
width: _boxWidth,
color: Colors.black54,
),
Align(
alignment: Alignment.bottomCenter,
child: SingleChildScrollView(
child: Column(
children: [
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 20, top: 60.0),
child: Expanded(
child: Text(
"এই লেখকের আরও কিছু বই",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white),
overflow: TextOverflow.clip,
),
),
),
Container(
padding: EdgeInsets.only(top: 10, bottom: 10),
height: 250.0,
child: FutureBuilder(
future: fetchBooks(),
builder: (context,
AsyncSnapshot<List<Book>> snapshot) {
if (!snapshot.hasData) {
return Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
CircularProgressIndicator(
backgroundColor: _whiteCream,
),
Text("Loading"),
],
);
} else {
var writterBooks = snapshot.data
.where((b) =>
b.author ==
widget.storyBooksValue.author)
.toList();
print(writterBooks.length);
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: writterBooks.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Route route = MaterialPageRoute(
builder: (context) =>
BookDescription(
storyBooksValue:
writterBooks[
index]),
);
Navigator.push(context, route);
},
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children: [
Container(
width: 100,
height: 140.0,
child: ClipRRect(
borderRadius:
BorderRadius
.circular(5.0),
child: FadeInImage
.assetNetwork(
fadeOutCurve:
Curves.linear,
placeholder:
'assets/images/cover.jpg',
image: writterBooks[
index]
.imgUrl ==
null
? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
: writterBooks[
index]
.imgUrl,
width: 90,
height: 120.0,
fit: BoxFit.cover,
),
),
),
Flexible(
child: Container(
width: 90,
child: Text(
"${writterBooks[index].name}",
style: TextStyle(
color:
Colors.white,
fontWeight:
FontWeight
.bold,
fontSize: 12.0),
overflow:
TextOverflow.clip,
),
),
),
],
),
),
);
});
}
},
),
),
],
),
),
Container(
width: _boxWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0)),
color: _whiteCream,
boxShadow: [
BoxShadow(
color: Colors.black45,
blurRadius: 5.0,
spreadRadius: 1.0)
],
),
child: Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
SizedBox(
height: 30.0,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Container(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
overflow: TextOverflow.clip,
text: TextSpan(
style: TextStyle(
color: Colors.black),
children: [
TextSpan(
text: "বইয়ের নামঃ",
style: TextStyle(
fontWeight:
FontWeight.bold,
fontSize: 16.0)),
TextSpan(
text:
" ${widget.storyBooksValue.name}")
]),
),
SizedBox(
height: 5.0,
),
RichText(
overflow: TextOverflow.clip,
text: TextSpan(
style: TextStyle(
color: Colors.black),
children: [
TextSpan(
text: "লেখকঃ",
style: TextStyle(
fontWeight:
FontWeight.bold,
fontSize: 16.0)),
TextSpan(
text:
" ${widget.storyBooksValue.author}")
]),
),
SizedBox(
height: 5.0,
),
RichText(
overflow: TextOverflow.clip,
text: TextSpan(
style: TextStyle(
color: Colors.black),
children: [
TextSpan(
text: "বইয়ের ধরণঃ",
style: TextStyle(
fontWeight:
FontWeight.bold,
fontSize: 16.0)),
TextSpan(
text:
" ${widget.storyBooksValue.genreClass}")
]),
),
],
),
),
),
Card(
elevation: 5.0,
child: FadeInImage.assetNetwork(
fadeOutCurve: Curves.easeInCubic,
placeholder: 'assets/images/cover.jpg',
image: widget.storyBooksValue.imgUrl ==
null
? "https://firebasestorage.googleapis.com/v0/b/boi-market.appspot.com/o/images%2Fcover.jpg?alt=media&token=f8070b25-533c-454b-9d2e-80702d72371e"
: widget.storyBooksValue.imgUrl,
height: 100.0,
fit: BoxFit.cover,
),
),
],
),
Divider(),
widget.storyBooksValue.description == null
? Center(
child: Text(
'দুঃখিত, ${widget.storyBooksValue.name} বইটির বর্ণনা পাওয়া যায়নি'))
: SelectableText(
'${widget.storyBooksValue.description} \n',
),
Text(
'আমরা বইটির একটি ebook খুজে পেয়েছি । \n\n আপনি বইটি পড়তে চাইলে, " Read Now " বাটনে ক্লিক করুন । \n'),
SizedBox(
height: 75.0,
)
],
),
),
),
],
),
),
)
],
),
),
Padding(
padding: EdgeInsets.only(left: 10.0, top: 20.0),
child: IconButton(
icon: Icon(Icons.arrow_back),
color: _whiteCream,
onPressed: () {
Navigator.pop(context, false);
}),
),
Positioned(
bottom: 60.0,
right: 20.0,
child: RaisedButton(
onPressed: () {
print("clicked");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PdfScreen(singleBookData: widget.storyBooksValue)),
);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
color: _darkBlue,
child: Text(
"Read now",
style: TextStyle(color: _whiteCream),
),
),
),
],
),
);
}
}
How can I fix this problem? please someone help me.
I solve my problem by remove container of text. Just use text() without container()
Expanded(
child: Text("এই লেখকের আরও কিছু বই",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white),
overflow: TextOverflow.clip,
),
)
For creating a release version of APP you can use android studio,
I am currently working on a flutter project when I create a release version of the app then the app only shows a white blank screen and nothing else, I tried everything to solve this but nothing seems to work, after searching for 2 days I come to know that using android studio we can also create a release version of the app, release version of the app using android studio solved my problem.
My personal choice is the android studio for flutter projects.
Here is the link to the question which I used to create the release version.
How to build signed apk from Android Studio for Flutter

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).