flutter how to display a list by scrolling - flutter

i want the popular menu to scroll down as i scroll on the whole page , not as it is right now scrolling only on that little part
its a Listview.builder inside a Listview
Demo : https://i.stack.imgur.com/TZ8xH.gif
here is the full code
its commented where the Listview and Listview.builder are
ctrl+f search this "//////" to quickly find them
import 'dart:async';
import 'package:custom_refresh_indicator/custom_refresh_indicator.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:foodninja/consts.dart';
import 'package:lottie/lottie.dart';
Color whiteBcg = const Color.fromARGB(255, 255, 255, 255);
Color limeColor = const Color.fromARGB(204, 77, 200, 118);
Color blackColor = Colors.black;
Color orangeInside = const Color.fromARGB(255, 210, 122, 0);
Color orangeOutside = const Color.fromARGB(45, 210, 123, 0);
Color cardBcg = const Color.fromRGBO(238, 238, 238, 1);
Color subText = const Color.fromARGB(255, 164, 164, 164);
class MyIconButton extends StatelessWidget {
const MyIconButton({
Key? key,
required this.icon,
required this.onClickAction,
}) : super(key: key);
final IconData icon;
final Function onClickAction;
#override
Widget build(BuildContext context) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: orangeOutside,
// border: Border.all(
// color: Colors.red,
// ),
borderRadius: BorderRadius.circular(15)),
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
const Color.fromARGB(2, 255, 149, 0)),
),
onPressed: () => onClickAction(),
child: Icon(
icon,
color: orangeInside,
),
));
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
double h = MediaQuery.of(context).size.height;
double w = MediaQuery.of(context).size.width;
return Scaffold(
body: CustomRefreshIndicator(
onRefresh: () {
return Future(
() {},
);
},
builder: (
BuildContext context,
Widget child,
IndicatorController controller,
) {
return AnimatedBuilder(
animation: controller,
builder: (BuildContext context, _) {
return Stack(
children: <Widget>[
if (controller.isDragging ||
controller.isArmed ||
controller.isLoading)
Positioned(
left: w * 0.37,
top: controller.value * 50,
child: SizedBox(
height: 100,
width: 100,
child: Transform.translate(
offset: Offset(0, controller.value * 20),
child: Transform.scale(
scale: controller.value *1.5,
child:
Lottie.asset("assets/burgerBounce.json"))),
),
),
// if (controller.isArmed)
// Positioned(
// left: 0,
// top: 25 * controller.value,
// child: SizedBox(
// height: 100,
// width: 100,
// child: Lottie.asset("assets/icecream.json"),
// ),
// ),
Transform.translate(
offset: const Offset(0, 0),
child: child,
)
],
);
},
);
},
child: ListView(physics: const BouncingScrollPhysics(), children: [ ///////the list view
SafeArea(
child: Stack(children: [
SizedBox(
width: 500,
child: Image.asset(
'assets/PhoneVerificationPattern.png',
fit: BoxFit.fill,
),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Find your \nfavorite food",
style: TextStyle(
fontSize: 35, fontWeight: FontWeight.bold),
),
MyIconButton(
icon: Icons.notifications_none,
onClickAction: () {},
),
]),
const SizedBox(
height: 20,
),
Container(
alignment: Alignment.center,
height: 70,
width: w,
decoration: BoxDecoration(
color: orangeOutside,
// border: Border.all(
// color: Colors.red,
// ),
borderRadius: BorderRadius.circular(15)),
child: TextFormField(
style: TextStyle(color: orangeInside),
decoration: InputDecoration(
hintText: "what do you want to order ?",
hintStyle: TextStyle(color: orangeInside),
prefixIconColor: orangeInside,
fillColor: orangeInside,
focusColor: orangeInside,
border: InputBorder.none,
focusedBorder: InputBorder.none,
prefixIcon: Icon(
Icons.search,
color: orangeInside,
),
contentPadding:
EdgeInsets.fromLTRB(0, 14, 0, 0))),
),
const SizedBox(
height: 20,
),
PromoAdvert(h: h, w: w),
const SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Nearest resturants",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
RichText(
text: TextSpan(
children: [
TextSpan(
text: "View more",
style: TextStyle(
fontSize: 15,
color: orangeInside,
),
recognizer: TapGestureRecognizer()
..onTap = () {}),
],
),
),
],
),
const SizedBox(
height: 15,
),
NearestResturants(w: w, h: h),
const SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Popular menu",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
RichText(
text: TextSpan(
children: [
TextSpan(
text: "View more",
style: TextStyle(
fontSize: 15,
color: orangeInside,
),
recognizer: TapGestureRecognizer()
..onTap = () {}),
],
),
),
],
),
const SizedBox(
height: 20,
),
SizedBox(
height: 70,
width: 400,
child: ListView.builder( ////////////////List view builder where the problem is
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: 4,
itemBuilder: (context, index) => Container(
height: 70,
width: 400,
decoration: BoxDecoration(
color: cardBcg,
// border: Border.all(
// color: Colors.red,
// ),
borderRadius: BorderRadius.circular(15)),
child: Row(
children: [
Padding(
padding:
const EdgeInsets.fromLTRB(9, 5, 0, 5),
child: Container(
width: 50,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
nearestResturantsContentList[index]
.image,
),
),
borderRadius: BorderRadius.circular(15),
),
),
),
const SizedBox(
width: 20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Fruit Salade ",
textAlign: TextAlign.start,
),
Text(
"Vegan resto",
textAlign: TextAlign.start,
style: TextStyle(color: subText),
),
],
),
const SizedBox(
width: 150,
),
Text(
"7\$",
textAlign: TextAlign.start,
style: TextStyle(
color: const Color.fromARGB(
255, 254, 171, 29),
fontSize: 23),
)
],
)),
),
),
],
),
)
]),
),
]),
),
);
}
}
class NearestResturantsContent {
late String image;
late String text;
late String subText;
NearestResturantsContent(
this.image,
this.text,
this.subText,
);
}
List<NearestResturantsContent> nearestResturantsContentList = [
NearestResturantsContent(
"assets/veganRestoLogo.png",
"veganResto",
"3KM",
),
NearestResturantsContent(
"assets/AjintiLogo.png",
"Ajinti",
"6KM",
),
NearestResturantsContent(
"assets/ChefGoLogo.png",
"ChefGo",
"10KM",
),
NearestResturantsContent(
"assets/BakeryLogo.png",
"Bakery",
"3KM",
),
NearestResturantsContent(
"assets/healthyFoodLogo.png",
"healthyFood",
"5KM",
),
NearestResturantsContent(
"assets/windowstoLogo.png",
"windowsto",
"3KM",
),
];
class NearestResturants extends StatelessWidget {
const NearestResturants({
Key? key,
required this.w,
required this.h,
}) : super(key: key);
final double w;
final double h;
#override
Widget build(BuildContext context) {
return SizedBox(
width: w,
height: h * 0.22,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: nearestResturantsContentList.length,
itemBuilder: (context, index) {
return Container(
margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
width: w * 0.4,
height: h * 0.22,
decoration: BoxDecoration(
color: cardBcg,
// border: Border.all(
// color: Colors.red,
// ),
borderRadius: BorderRadius.circular(15)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
child: SizedBox(
height: 90,
width: 90,
child: Image.asset(
nearestResturantsContentList[index].image,
fit: BoxFit.fill,
),
),
),
Text(
nearestResturantsContentList[index].text,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
overflow: TextOverflow.ellipsis),
),
const SizedBox(
height: 5,
),
Text(
nearestResturantsContentList[index].subText,
style: TextStyle(
color: subText,
fontSize: 13,
fontWeight: FontWeight.bold,
overflow: TextOverflow.ellipsis),
),
],
),
);
},
),
);
}
}
class PromoAdvertContent {
late String image;
late String text;
late String subText;
late Color color;
PromoAdvertContent(this.image, this.text, this.subText, this.color);
}
List<PromoAdvertContent> promoAdvertContentList = [
PromoAdvertContent("assets/promoAdvert.png", "Special deal for \nOctober",
"Buy now", limeColor),
PromoAdvertContent("assets/promoAdvert.png", "Special deal for \nOctober",
"check out", orangeInside),
PromoAdvertContent(
"assets/promoAdvert.png", "No way this \nOctober", "check out", subText)
];
class PromoAdvert extends StatelessWidget {
const PromoAdvert({
Key? key,
required this.h,
required this.w,
}) : super(key: key);
final double h;
final double w;
#override
Widget build(BuildContext context) {
bool isScrollingToRight = true;
int currentPage = 0;
PageController scrollController = PageController(initialPage: 0);
void _scrollToBottom() {
if (currentPage < promoAdvertContentList.length && isScrollingToRight) {
currentPage++;
} else if (!isScrollingToRight && currentPage == 0) {
currentPage++;
isScrollingToRight = true;
} else {
isScrollingToRight = false;
currentPage--;
}
if (scrollController.hasClients) {
scrollController.animateToPage(
currentPage,
duration: const Duration(milliseconds: 1000),
curve: Curves.easeOut,
);
}
}
WidgetsBinding.instance.addPostFrameCallback(
(_) => Timer.periodic(const Duration(seconds: 15), (_) {
_scrollToBottom();
}));
return SizedBox(
width: w,
height: h * 0.217,
child: CustomRefreshIndicator(
onRefresh: () {
return Future(
() {},
);
},
builder: (
BuildContext context,
Widget child,
IndicatorController controller,
) {
return AnimatedBuilder(
animation: controller,
builder: (BuildContext context, _) {
return Stack(
children: <Widget>[
if (controller.isDragging ||
controller.isArmed ||
controller.isLoading)
Positioned(
left: 0,
top: h * 0.05,
child: SizedBox(
height: 100,
width: 100,
child: Transform.translate(
offset: Offset(-controller.value * 20, 0),
child: Transform.rotate(
angle: 11,
child: Lottie.asset("assets/icecream.json"))),
),
),
// if (controller.isArmed)
// Positioned(
// left: 0,
// top: 25 * controller.value,
// child: SizedBox(
// height: 100,
// width: 100,
// child: Lottie.asset("assets/icecream.json"),
// ),
// ),
Transform.translate(
offset: const Offset(0, 0),
child: child,
)
],
);
},
);
},
child: PageView.builder(
controller: scrollController,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: promoAdvertContentList.length,
itemBuilder: (context, index) {
if (promoAdvertContentList.length == index) {
print('a"sqdqsqs');
CircularProgressIndicator();
}
return Container(
width: h * 0.47,
height: 160,
decoration: BoxDecoration(
color: promoAdvertContentList[index].color,
// border: Border.all(
// color: Colors.red,
// ),
borderRadius: BorderRadius.circular(15)),
child: Stack(children: [
SizedBox(
height: 160,
width: h * 0.47,
child: Image.asset(
promoAdvertContentList[index].image,
fit: BoxFit.fill,
),
),
Positioned(
top: 30,
right: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
promoAdvertContentList[index].text,
style: TextStyle(
color: whiteBcg,
fontSize: 20,
fontWeight: FontWeight.bold),
),
const SizedBox(
height: 10,
),
NextButton(
h: h,
w: w,
text: promoAdvertContentList[index].subText,
)
],
))
]),
);
},
),
),
);
}
}
class NextButton extends StatelessWidget {
const NextButton({
Key? key,
required this.h,
required this.w,
required this.text,
}) : super(key: key);
final double h;
final double w;
final String text;
#override
Widget build(BuildContext context) {
return Center(
child: SizedBox(
height: 45,
width: 100,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
elevation: 5,
child: TextButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
)),
backgroundColor: MaterialStateProperty.all<Color>(whiteBcg)),
onPressed: () {},
child: Text(
text,
style: TextStyle(color: limeColor, fontSize: 15),
overflow: TextOverflow.ellipsis,
softWrap: false,
)),
),
),
);
}
}

To the list view that is scrolling separately add physics
physics: NeverScrollableScrollPhysics(),
And remove sized box which is wrapping the listview

Related

How to change circularprogressindicator in Center

I'm having a little problem here, I want to map a circularprogressindicator in the middle of the page but it just appears in the top center of the page, how do I move it to the middle of the page, I've tried wrapping it using the Column widget but an error occurs. How do I solve this simple problem.
and one more how do I add a hintText in the dropdown as the default value, because the dropdown immediately takes the value 1.
Thank you.
note:
green color for dropdown case
red for circularprogressindicator cases
Here I attach the code.
class JadwalKuliah extends StatefulWidget {
const JadwalKuliah({super.key});
#override
State<JadwalKuliah> createState() => _JadwalKuliahState();
}
class _JadwalKuliahState extends State<JadwalKuliah> {
String? _selectedItem1;
List<int> listitems = [1, 2, 3, 4, 5, 6, 7, 8];
int semester = 1;
List<Datum> data = [];
#override
void initState() {
super.initState();
fetchData(semester);
}
fetchData(int smt) async {
final apiResponse = await JadwalKuliahProvider.getJadwalKuliah(smt);
setState(() {
data = (apiResponse);
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: CustomAppbar(
title: 'Jadwal Kuliah',
),
),
body: Center(
child: Padding(
padding: const EdgeInsets.only(
left: 14,
top: 14,
right: 14,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Header(),
listJadwal(),
],
),
),
),
);
}
Widget Header() {
return Container(
padding: const EdgeInsets.only(left: 12, right: 8),
width: double.infinity,
height: 50,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 9,
offset: const Offset(
1,
2,
),
),
],
),
child: DropdownButtonHideUnderline(
child: DropdownButton(
// hint: const Text('Pilih Semester'),
value: semester,
onChanged: (value) {
setState(
() {
semester = value!;
},
);
fetchData(value!);
},
hint: const SizedBox(
width: 150, //and here
child: Text(
"Pilih Semester",
style: TextStyle(color: Colors.grey),
),
),
items: listitems.map(
(itemone) {
return DropdownMenuItem(
value: itemone, child: Text(itemone.toString()));
},
).toList(),
),
),
);
}
Widget listJadwal() {
return FutureBuilder<List<Datum>>(
future: JadwalKuliahProvider.getJadwalKuliah(semester),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Expanded(
child: ListView.builder(
padding: const EdgeInsets.only(
top: 10,
),
physics: const BouncingScrollPhysics(),
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(top: 14),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(
Radius.circular(
10,
),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 9,
offset: const Offset(
1, 2), // changes position of shadow
),
],
),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
// "Audit Bank Syariah (SPI)",
snapshot.data![index].nmMk.toString(),
style: bold6,
),
Text(
snapshot.data![index].dosenAjar!.nmDosen.toString(),
style: regular7,
),
Text(
// "Perbankan Syariah",
snapshot.data![index].prodi.toString(),
style: regular7,
),
const SizedBox(
height: 5,
),
Row(
children: [
Container(
height: 30,
width: 70,
decoration: BoxDecoration(
color: const Color(0xffECECEC),
borderRadius: BorderRadius.circular(5)),
child: Padding(
padding: const EdgeInsets.all(5),
child: Row(
children: [
Icon(
Icons.location_on_outlined,
color: greyColor,
size: 18,
),
const SizedBox(
width: 3,
),
Text(
'A201',
// snapshot.data![index]
// .dosenAjar!.nmDosen
// .toString(),
style: bold6.copyWith(color: greyColor),
),
],
),
),
),
const SizedBox(
width: 10,
),
Container(
height: 30,
width: 120,
decoration: BoxDecoration(
color: const Color(0xffECECEC),
borderRadius: BorderRadius.circular(5)),
child: Padding(
padding: const EdgeInsets.all(5),
child: Row(
children: [
Icon(
Icons.watch_later_outlined,
color: greyColor,
size: 18,
),
const SizedBox(
width: 3,
),
const SizedBox(
width: 3,
),
Text(
// snapshot
// .data![index].jamAwal
// .toString(),
'09:00',
style: bold6.copyWith(
color: greyColor,
),
),
const SizedBox(
width: 3,
),
Text(
'-',
// snapshot
// .data![index].jamAkhir
// .toString(),
style: bold6.copyWith(
color: greyColor,
),
),
const SizedBox(
width: 3,
),
Text(
'12:00',
// snapshot
// .data![index].jamAkhir
// .toString(),
style: bold6.copyWith(
color: greyColor,
),
),
],
),
),
),
const SizedBox(
width: 10,
),
SizedBox(
height: 30,
width: 100,
child: ElevatedButton.icon(
onPressed: () {},
icon: const Icon(
Icons.download,
size: 17,
color: Color(0xffCEE1FF),
),
label: Text(
'Materi',
style: bold6,
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff0062FF),
),
),
),
],
),
const SizedBox(
height: 10,
),
Container(
width: double.infinity,
height: 38,
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: const Color(0xffC9F7F5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
"Absen",
style: bold5.copyWith(
color: const Color(
0xff1BC5BD,
),
),
),
),
),
],
),
),
);
}),
);
} else {
return Center(
child: CircularProgressIndicator(color: primaryColor),
);
}
},
);
In your listJadwal change CircularProgressIndicator to this:
} else {
return Expanded(
child: Center(
child: CircularProgressIndicator(color: primaryColor),
),
);
}
Try below code I have same issue occurred I resolve this following code:
SizedBox(
height: MediaQuery.of(context).size.height / 1.0,//change on your need
child: Center(
child: CircularProgressIndicator(color: primaryColor),
),
),
Try this, Column will use your full screen size to center the widget
body: Column(mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: CircularProgressIndicator(),
)
],),

Flutter ; Vertical ListView inside a column(inside another column) causing an overflow

class Episodes extends StatefulWidget {
const Episodes({super.key});
#override
State<Episodes> createState() => _EpisodesState();
}
class _EpisodesState extends State<Episodes> {
final seasons = ['Season 1', 'Season 2', 'Season 3'];
String? value;
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
//EdgeInsets.only(left: size.width * 0.03, right: size.width * 0.03),
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Container(
height: size.height * 0.045,
width: size.width * 0.25,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.25),
borderRadius: BorderRadius.circular(5)),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: value,
alignment: Alignment.center,
isExpanded: true,
//icon: Icon(Icons.arrow_drop_down_outlined,
// size: 12, color: Colors.white),
iconEnabledColor: Colors.white,
//dropdownColor: Colors.transparent,
items: seasons.map(buildMenuItem).toList(),
dropdownColor: Colors.grey.withOpacity(0.3),
onChanged: (value) => setState(() {
this.value = value;
}),
),
),
),
SizedBox(height: size.height * 0.02),
ListView.builder(
shrinkWrap: true,
//physics: const AlwaysScrollableScrollPhysics(),
itemCount: 15,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Container(
color: Colors.red,
height: 15,
width: 15,
),
);
},
),
],
),
);
}
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
value: item,
child: Center(
child: Text(
item,
style: GoogleFonts.poppins(color: Colors.white, fontSize: 12),
),
));
}
Im trying to build a netflix clone, and this is the design of the episode list in the title page.
Basically, im trying to include listview.builder(vertical) inside a column; but im getting an overflow error.
This column is furthur getting returned as one of the children of a parent column in another file.
Till now ive tried wrapping the column under :
*SingleChildScrollView,
*Expanded
*SizedBox, Container : with fixed height
None of the above worked; i even tried playing around with the scroll physics, didnt work, the overflow error still persisted.
Im new to flutter; i just wanna get rid of the overflow error. Any help will be appreciated!
Furthur im looking to dynamically fetch details from firebase and display them here. Any tips on that will be appreciated as well!
Main file structure :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:netflixclone/ContentPages/tabbar_pg.dart';
import 'package:video_player/video_player.dart';
//UpperNavBar
//video preview
//Container
//Name
//{List of particulars}
//Play Btn
//Download Btn
//Description
//Strarring
//creator
//Row List : List, Rate, Share, Download S1.
//Tab Bar : Episodes, TrailersNMore, MoreLikeThis
//DropDownList : Seasons list
//Episodes : E1 : Container :{}..
//TrailersNMore : Vidoes
//MoreLikeThis : 9 random suggestions. : if i can ill do.
class TitlePage extends StatefulWidget {
const TitlePage({super.key});
#override
State<TitlePage> createState() => _TitlePageState();
}
class _TitlePageState extends State<TitlePage> {
int current = 0;
#override
Widget build(BuildContext context) {
List<String> items = [
"EPISODES",
"TRAILERS & MORE",
"MORE LIKE THIS",
];
List<Widget> itemsPages = [
Episodes(),
TrailersNMore(),
MoreLikeThis(),
];
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(size.height * 0.05),
child: UpperAppBar(),
),
backgroundColor: Colors.black,
body: Padding(
padding: EdgeInsets.only(top: size.height * 0.007),
child: Column(
children: [
Container(child: VideoController()),
Container(
child: Padding(
padding: EdgeInsets.only(
left: size.width * 0.02,
top: size.height * 0.01,
right: size.width * 0.02),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Peaky Blinders",
style: GoogleFonts.comfortaa(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.w900)),
Padding(
padding: EdgeInsets.only(top: size.height * 0.008),
child: Row(
children: [
Text("2022",
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 16,
fontWeight: FontWeight.w500)),
SizedBox(width: size.width * 0.03),
Container(
width: size.width * 0.033,
height: size.height * 0.024,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.5)),
child: Center(
child: Text("A",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 16,
fontWeight: FontWeight.w500)),
),
),
SizedBox(width: size.width * 0.03),
Text("6-Seasons",
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 16,
fontWeight: FontWeight.w500)),
SizedBox(width: size.width * 0.03),
Icon(Icons.comment_rounded,
size: 25, color: Colors.white.withOpacity(0.8))
],
),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.white),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
fixedSize: MaterialStateProperty.all<Size>(
Size.fromWidth(size.width))),
onPressed: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.play_arrow,
color: Colors.black,
size: 22,
),
SizedBox(width: size.width * 0.01),
Text('Play',
style: GoogleFonts.poppins(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold))
]),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Colors.grey.withOpacity(0.25)),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
fixedSize: MaterialStateProperty.all<Size>(
Size.fromWidth(size.width))),
onPressed: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.download_outlined,
color: Colors.white,
size: 20,
),
SizedBox(width: size.width * 0.01),
Text('Download',
style: GoogleFonts.poppins(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold)),
SizedBox(width: size.width * 0.01),
Text('S1:E1',
style: GoogleFonts.poppins(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold)),
]),
),
Text(
'A notorious gang in 1919 Birminham, England, is led by the fierce Tommy Shelby, a crime boss set on moving up in the world no matter the cost.',
style: GoogleFonts.poppins(
color: Colors.white, fontSize: 12),
),
SizedBox(height: size.height * 0.01),
Row(
children: [
Text(
'Starring: ',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 12),
),
Text(
'Cillian Murphy,Sam Neill, Helen McCory',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 12),
),
GestureDetector(
onTap: () => null,
child: Text(
'...more',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 12),
),
),
],
),
Row(
children: [
Text(
'Creator: ',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.99),
fontSize: 12),
),
Text(
'Steven Knight',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 12),
),
],
),
SizedBox(height: size.height * 0.01),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.check,
color: Colors.white,
size: 30,
)),
Text(
'My List',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.thumb_up_alt_outlined,
color: Colors.white,
size: 30,
)),
Text(
'Rate',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.share,
color: Colors.white,
size: 30,
)),
Text(
'Share',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.download_rounded,
color: Colors.white,
size: 30,
)),
Text(
'Download Season 1',
style: GoogleFonts.poppins(
color: Colors.grey.withOpacity(0.7),
fontSize: 10),
)
],
),
),
],
)
],
),
),
),
Divider(
height: size.height * 0.01,
),
Container(
color: Colors.grey.withOpacity(0.7),
height: size.height * 0.002,
),
//TabBar :
Padding(
padding: EdgeInsets.only(
left: size.width * 0.03, right: size.width * 0.03),
child: SizedBox(
width: double.infinity,
height: 60,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: items.length,
scrollDirection: Axis.horizontal,
itemBuilder: (ctx, index) {
return GestureDetector(
onTap: () => setState(() {
current = index;
}),
child: Padding(
padding: EdgeInsets.only(right: size.width * 0.1),
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
decoration: BoxDecoration(
border: current == index
? Border(
top: BorderSide(
color: Color.fromARGB(255, 225, 26, 12),
width: size.height * 0.005),
)
: Border(
top: BorderSide(
color: Colors.black,
width: size.height * 0.005),
),
),
child: Text(items[index],
style: GoogleFonts.bebasNeue(
fontSize: 22,
fontWeight: FontWeight.w500,
color: current == index
? Colors.white
: Colors.grey.withOpacity(0.99))),
),
),
);
},
),
),
),
itemsPages[current],
//Episodes()
// Container(
// width: double.infinity,
// child: itemsPages[current],
// ),
],
),
),
);
}
Widget UpperAppBar() {
return AppBar(
backgroundColor: Colors.black,
leading: Icon(
Icons.arrow_back,
color: Colors.white,
size: 30,
),
actions: [
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
size: 30,
),
onPressed: null,
),
IconButton(
icon: Image.asset('assets/Images/ProfileImg.jpg', width: 30),
onPressed: null,
)
],
);
}
}
class VideoController extends StatefulWidget {
const VideoController({super.key});
#override
State<VideoController> createState() => _VideoPlayerState();
}
class _VideoPlayerState extends State<VideoController> {
late VideoPlayerController controller;
final asset = 'assets/Videos/SoClose-ThomasShelby.mp4';
#override
void initState() {
super.initState();
controller = VideoPlayerController.asset(asset)
..addListener(() => setState(() {}))
..setLooping(
true) //if u can after vid finishes : pause it and add a peaky blinders logo
..initialize().then((_) => controller.play());
}
#override
void dispose() {
controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
final isMuted = controller.value.volume == 0;
return Stack(children: [
VideoPlayerWidget(controller: controller),
if (controller != null && controller.value.isInitialized)
Positioned(
top: size.height * 0.185,
left: size.width * 0.85,
child: IconButton(
icon: Icon(
isMuted ? Icons.volume_off : Icons.volume_up,
color: Colors.white,
size: 20,
),
onPressed: () => controller.setVolume(isMuted ? 1 : 0),
),
),
Positioned(
top: size.height * 0.205,
left: size.width * 0.02,
child: Container(
width: size.width * 0.16,
height: size.height * 0.026,
decoration: BoxDecoration(color: Colors.black.withOpacity(0.39)),
child: Center(
child: Text('Preview',
style: GoogleFonts.ptSans(color: Colors.white, fontSize: 15)),
),
),
)
]);
}
}
class VideoPlayerWidget extends StatelessWidget {
final VideoPlayerController controller;
const VideoPlayerWidget({
Key? key,
required this.controller,
}) : super(key: key);
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return controller != null && controller.value.isInitialized
? Container(
alignment: Alignment.topCenter,
child: buildVideo(),
)
: Container(
height: 100,
child: Center(child: CircularProgressIndicator()),
);
}
Widget buildVideo() => Stack(children: <Widget>[
buildVideoPlayer(),
Positioned.fill(child: BasicOverlayWidget(controller: controller)),
]);
Widget buildVideoPlayer() => AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: VideoPlayer(controller));
}
class BasicOverlayWidget extends StatelessWidget {
final VideoPlayerController controller;
const BasicOverlayWidget({
Key? key,
required this.controller,
}) : super(key: key);
#override
Widget build(BuildContext context) => GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () =>
controller.value.isPlaying ? controller.pause() : controller.play(),
child: Stack(
children: <Widget>[
buildPlay(),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: buildIndicator(),
),
],
),
);
Widget buildIndicator() => VideoProgressIndicator(
controller,
allowScrubbing: true,
colors: VideoProgressColors(
backgroundColor: Color.fromARGB(255, 115, 11, 3),
playedColor: Color.fromARGB(255, 225, 26, 12)),
);
Widget buildPlay() => controller.value.isPlaying
? Container()
: Container(
alignment: Alignment.center,
color: Colors.black26,
child: Icon(Icons.play_arrow, color: Colors.white, size: 80),
);
}
From what i understand you have something like this on the main page:
Column(children : [
SomeWidget(),
OtherWidget(),
Episodes(),
]);
Since Episodes() is in Column, it's been given infinite height. You should wrap it in an Expanded() widget if you want it to get the remaining height of the page, like below.
Column(children : [
SomeWidget(),
OtherWidget(),
Expanded(child:Episodes()),
]);
If this doesn't fix your problem, please give more informations about the parent widget (where Episodes is used).
The scaffold wrapper was missing and I fixed it
I added Area to prevent the height of the MenuItem popup from exceeding the top of the screen
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class Episodes extends StatefulWidget {
const Episodes({super.key});
#override
State<Episodes> createState() => _EpisodesState();
}
class _EpisodesState extends State<Episodes> {
final seasons = ['Season 1', 'Season 2', 'Season 3'];
String? value;
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
//EdgeInsets.only(left: size.width * 0.03, right: size.width * 0.03),
return SafeArea(
child: Scaffold(
body: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Container(
height: size.height * 0.045,
width: size.width * 0.25,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.25),
borderRadius: BorderRadius.circular(5)),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: value,
alignment: Alignment.center,
isExpanded: true,
//icon: Icon(Icons.arrow_drop_down_outlined,
// size: 12, color: Colors.white),
iconEnabledColor: Colors.white,
//dropdownColor: Colors.transparent,
items: seasons.map(buildMenuItem).toList(),
dropdownColor: Colors.grey.withOpacity(0.3),
onChanged: (value) => setState(() {
this.value = value;
}),
),
),
),
SizedBox(height: size.height * 0.02),
ListView.builder(
shrinkWrap: true,
//physics: const AlwaysScrollableScrollPhysics(),
itemCount: 15,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Container(
color: Colors.red,
height: 15,
width: 15,
),
);
},
),
],
),
),
));
}
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
value: item,
child: Center(
child: Text(
item,
// style: GoogleFonts.poppins(color: Colors.white, fontSize: 12),
),
));
}
//UpperNavBar
//video preview
//Container
//Name
//{List of particulars}
//Play Btn
//Download Btn
//Description
//Strarring
//creator
//Row List : List, Rate, Share, Download S1.
//Tab Bar : Episodes, TrailersNMore, MoreLikeThis
//DropDownList : Seasons list
//Episodes : E1 : Container :{}..
//TrailersNMore : Vidoes
//MoreLikeThis : 9 random suggestions. : if i can ill do.
class TitlePage extends StatefulWidget {
const TitlePage({super.key});
#override
State<TitlePage> createState() => _TitlePageState();
}
class _TitlePageState extends State<TitlePage> {
int current = 0;
#override
Widget build(BuildContext context) {
List<String> items = [
"EPISODES",
"TRAILERS & MORE",
"MORE LIKE THIS",
];
List<Widget> itemsPages = [
Episodes(),
Expanded(
child: Column(
children: [
ListView(
shrinkWrap: true,
children: [
...List.generate(
10,
(index) => ListTile(
title: Text('$index'),
))
],
)
],
),
),
Expanded(
child: Column(
children: [
// TrailersNMore(),
// MoreLikeThis(),
],
))
];
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(size.height * 0.05),
child: UpperAppBar(),
),
backgroundColor: Colors.black,
body: Padding(
padding: EdgeInsets.only(top: size.height * 0.007),
child: Column(
children: [
Container(child: VideoController()),
Container(
child: Padding(
padding: EdgeInsets.only(
left: size.width * 0.02,
top: size.height * 0.01,
right: size.width * 0.02),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Peaky Blinders",
// style: GoogleFonts.comfortaa(
// color: Colors.white,
// fontSize: 30,
// fontWeight: FontWeight.w900),
),
Padding(
padding: EdgeInsets.only(top: size.height * 0.008),
child: Row(
children: [
Text(
"2022",
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 16,
// fontWeight: FontWeight.w500),
),
SizedBox(width: size.width * 0.03),
Container(
width: size.width * 0.033,
height: size.height * 0.024,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.5)),
child: Center(
child: Text(
"A",
textAlign: TextAlign.center,
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 16,
// fontWeight: FontWeight.w500),
),
),
),
SizedBox(width: size.width * 0.03),
Text(
"6-Seasons",
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 16,
// fontWeight: FontWeight.w500),
),
SizedBox(width: size.width * 0.03),
Icon(Icons.comment_rounded,
size: 25, color: Colors.white.withOpacity(0.8))
],
),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.white),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
fixedSize: MaterialStateProperty.all<Size>(
Size.fromWidth(size.width))),
onPressed: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.play_arrow,
color: Colors.black,
size: 22,
),
SizedBox(width: size.width * 0.01),
Text(
'Play',
// style: GoogleFonts.poppins(
// color: Colors.black,
// fontSize: 16,
// fontWeight: FontWeight.bold),
)
]),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Colors.grey.withOpacity(0.25)),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
),
fixedSize: MaterialStateProperty.all<Size>(
Size.fromWidth(size.width))),
onPressed: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.download_outlined,
color: Colors.white,
size: 20,
),
SizedBox(width: size.width * 0.01),
Text(
'Download',
// style: GoogleFonts.poppins(
// color: Colors.white,
// fontSize: 16,
// fontWeight: FontWeight.bold)
),
SizedBox(width: size.width * 0.01),
Text(
'S1:E1',
// style: GoogleFonts.poppins(
// color: Colors.white,
// fontSize: 16,
// fontWeight: FontWeight.bold),
),
]),
),
Text(
'A notorious gang in 1919 Birminham, England, is led by the fierce Tommy Shelby, a crime boss set on moving up in the world no matter the cost.',
// style: GoogleFonts.poppins(
// color: Colors.white, fontSize: 12),
),
SizedBox(height: size.height * 0.01),
Row(
children: [
Text(
'Starring: ',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 12),
),
Text(
'Cillian Murphy,Sam Neill, Helen McCory',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 12),
),
GestureDetector(
onTap: () => null,
child: Text(
'...more',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 12),
),
),
],
),
Row(
children: [
Text(
'Creator: ',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.99),
// fontSize: 12),
),
Text(
'Steven Knight',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 12),
),
],
),
SizedBox(height: size.height * 0.01),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.check,
color: Colors.white,
size: 30,
)),
Text(
'My List',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.thumb_up_alt_outlined,
color: Colors.white,
size: 30,
)),
Text(
'Rate',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.share,
color: Colors.white,
size: 30,
)),
Text(
'Share',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 10),
)
],
),
),
InkWell(
splashColor: Colors.grey.withOpacity(0.8),
child: Column(
children: [
IconButton(
onPressed: () => null,
icon: Icon(
Icons.download_rounded,
color: Colors.white,
size: 30,
)),
Text(
'Download Season 1',
// style: GoogleFonts.poppins(
// color: Colors.grey.withOpacity(0.7),
// fontSize: 10),
)
],
),
),
],
)
],
),
),
),
Divider(
height: size.height * 0.01,
),
Container(
color: Colors.grey.withOpacity(0.7),
height: size.height * 0.002,
),
//TabBar :
Padding(
padding: EdgeInsets.only(
left: size.width * 0.03, right: size.width * 0.03),
child: SizedBox(
width: double.infinity,
height: 60,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: items.length,
scrollDirection: Axis.horizontal,
itemBuilder: (ctx, index) {
return GestureDetector(
onTap: () => setState(() {
current = index;
}),
child: Padding(
padding: EdgeInsets.only(right: size.width * 0.1),
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
decoration: BoxDecoration(
border: current == index
? Border(
top: BorderSide(
color: Color.fromARGB(255, 225, 26, 12),
width: size.height * 0.005),
)
: Border(
top: BorderSide(
color: Colors.black,
width: size.height * 0.005),
),
),
child: Text(
items[index],
// style: GoogleFonts.bebasNeue(
// fontSize: 22,
// fontWeight: FontWeight.w500,
// color: current == index
// ? Colors.white
// : Colors.grey.withOpacity(0.99)),
),
),
),
);
},
),
),
),
itemsPages[current],
//Episodes()
// Container(
// width: double.infinity,
// child: itemsPages[current],
// ),
],
),
),
);
}
Widget UpperAppBar() {
return AppBar(
backgroundColor: Colors.black,
leading: Icon(
Icons.arrow_back,
color: Colors.white,
size: 30,
),
actions: [
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
size: 30,
),
onPressed: null,
),
IconButton(
icon: Image.asset('assets/Images/ProfileImg.jpg', width: 30),
onPressed: null,
)
],
);
}
}
class VideoController extends StatefulWidget {
const VideoController({super.key});
#override
State<VideoController> createState() => _VideoPlayerState();
}
class _VideoPlayerState extends State<VideoController> {
late VideoPlayerController controller;
final asset = 'assets/Videos/SoClose-ThomasShelby.mp4';
#override
void initState() {
super.initState();
controller = VideoPlayerController.asset(asset)
..addListener(() => setState(() {}))
..setLooping(
true) //if u can after vid finishes : pause it and add a peaky blinders logo
..initialize().then((_) => controller.play());
}
#override
void dispose() {
controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
final isMuted = controller.value.volume == 0;
return Stack(children: [
VideoPlayerWidget(controller: controller),
if (controller != null && controller.value.isInitialized)
Positioned(
top: size.height * 0.185,
left: size.width * 0.85,
child: IconButton(
icon: Icon(
isMuted ? Icons.volume_off : Icons.volume_up,
color: Colors.white,
size: 20,
),
onPressed: () => controller.setVolume(isMuted ? 1 : 0),
),
),
Positioned(
top: size.height * 0.205,
left: size.width * 0.02,
child: Container(
width: size.width * 0.16,
height: size.height * 0.026,
decoration: BoxDecoration(color: Colors.black.withOpacity(0.39)),
child: Center(
child: Text(
'Preview',
// style: GoogleFonts.ptSans(color: Colors.white, fontSize: 15),
),
),
),
)
]);
}
}
class VideoPlayerWidget extends StatelessWidget {
final VideoPlayerController controller;
const VideoPlayerWidget({
Key? key,
required this.controller,
}) : super(key: key);
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return controller != null && controller.value.isInitialized
? Container(
alignment: Alignment.topCenter,
child: buildVideo(),
)
: Container(
height: 100,
child: Center(child: CircularProgressIndicator()),
);
}
Widget buildVideo() => Stack(children: <Widget>[
buildVideoPlayer(),
Positioned.fill(child: BasicOverlayWidget(controller: controller)),
]);
Widget buildVideoPlayer() => AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: VideoPlayer(controller));
}
class BasicOverlayWidget extends StatelessWidget {
final VideoPlayerController controller;
const BasicOverlayWidget({
Key? key,
required this.controller,
}) : super(key: key);
#override
Widget build(BuildContext context) => GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () =>
controller.value.isPlaying ? controller.pause() : controller.play(),
child: Stack(
children: <Widget>[
buildPlay(),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: buildIndicator(),
),
],
),
);
Widget buildIndicator() => VideoProgressIndicator(
controller,
allowScrubbing: true,
colors: VideoProgressColors(
backgroundColor: Color.fromARGB(255, 115, 11, 3),
playedColor: Color.fromARGB(255, 225, 26, 12)),
);
Widget buildPlay() => controller.value.isPlaying
? Container()
: Container(
alignment: Alignment.center,
color: Colors.black26,
child: Icon(Icons.play_arrow, color: Colors.white, size: 80),
);
}

I want to Hide some widgets from SliverAppbar On Scroll Flutter

enter image description here
Hello, I want to keep and hide few things on scroll from SliverAppBar bottom section. For example, when I scroll the list from top to bottom, the logo , branch, distance, etc should hide. The leading, title, actions, and restaurant title will be shown. Below is my code, Can anyone please help?
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:urmenuz/constants/styles.dart';
import 'package:urmenuz/widgets/hidable/hidable.dart';
import '../../constants/colors.dart';
import '../../constants/configs.dart';
import '../../utils/rating_bar.dart';
import 'package:flutter/rendering.dart';
class MenuHeader extends SliverAppBar {
final expandedHeight;
final collapsedHeight;
final bool dineIn;
final Function backFunction;
final Function menuFunction;
final Function infoFunction;
final Function serviceIconFunction;
final Widget tblTextField;
final ScrollController scrollController;
MenuHeader({
this.expandedHeight = 350,
this.collapsedHeight = 160,
this.dineIn = true,
required this.backFunction,
required this.menuFunction,
required this.infoFunction,
required this.serviceIconFunction,
required this.scrollController,
required this.tblTextField,
}) : super(
elevation: 0.0,
pinned: true,
floating: false,
snap: false,
forceElevated: true);
Color? get backgroundColor => AppColors.lightGrey;
// #override
// Widget? get background => Image.asset(IMAGE_ASSET_DIR + 'background2.png',
// fit: BoxFit.cover,
// );
#override
Widget? get leading {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: GestureDetector(
onTap: () => backFunction(),
child: Container(
height: 36,
width: 36,
decoration: BoxDecoration(
color: AppColors.lightRed,
borderRadius: BorderRadius.circular(10)),
child: Center(
child: Icon(
Icons.arrow_back_ios_new,
color: Colors.black,
)),
),
),
);
}
#override
Widget? get title {
return Text(
'urMenu',
style: TextStyle(
color: AppColors.lightGrey,
fontWeight: FontWeight.w600,
fontSize: 20),
);
}
#override
List<Widget>? get actions {
return [
Row(
children: [
GestureDetector(
onTap: () => serviceIconFunction(),
child: Image.asset(
IMAGE_ASSET_DIR + "${dineIn ? "dine_in" : "pick_up"}.png",
height: 40,
width: 40,
),
),
SizedBox(
width: 20,
),
Container(
height: 36,
width: 36,
margin: EdgeInsets.only(right: 20),
decoration: BoxDecoration(
color: AppColors.lightRed,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: AppColors.grey.withOpacity(0.1),
offset: Offset(0.0, 0.0), //(x,y)
blurRadius: 4.0,
),
],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () => menuFunction(),
child: Image.asset(
IMAGE_ASSET_DIR + 'menu.png',
color: Colors.black,
)),
)),
],
),
];
}
#override
PreferredSizeWidget? get bottom {
return PreferredSize(
preferredSize: const Size.fromHeight(70),
child: Container(
color: Colors.transparent,
height: 160,
child: Padding(
padding: const EdgeInsets.only(bottom: 50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// color: Colors.yellow,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
offset: Offset(0.0, 1.0), //(x,y)
blurRadius: 6.0,
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR7-G-E4aXWzIoakYj-4VpNF8tp5hiaUC5K7yZGDaEjaNddIRMWcvV9lJU1_3F1q_RVqIM&usqp=CAU",
height: 75,
width: 75,
),
),
),
],
),
),
const SizedBox(
width: 12,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
// SizedBox(
// height: 3,
// ),
const Text(
"Branch",
style: TextStyle(
color: AppColors.lightGrey,
fontSize: 14,
fontWeight: FontWeight.w500),
),
const SizedBox(
height: 3,
),
Text(
"The Butcher Shop & Grill",
maxLines: 1,
softWrap: true,
// .toUpperCase(),
style: const TextStyle(
color: AppColors.lightGrey,
fontSize: 20,
fontWeight: FontWeight.bold),
),
const SizedBox(
height: 6,
),
buildRatebar(12, 6, gap: .9),
]),
],
),
// Positioned(
// right: 20,
// child: GestureDetector(
// onTap: () => infoFunction(),
// child: Container(
// decoration: BoxDecoration(
// color: AppColors.lightGrey,
// borderRadius: BorderRadius.circular(20)),
// child: Padding(
// padding: EdgeInsets.all(3),
// child: Image.asset(
// IMAGE_ASSET_DIR + 'info_icon_single.png',
// height: 12,
// width: 12,
// color: dineIn ? AppColors.red : AppColors.orange,
// ),
// )),
// ),
// )
],
),
Padding(
padding: const EdgeInsets.only(right: 20, left: 20, top: 10),
child: Row(
children: [
if (dineIn) tblTextField,
// Text(
// '+ Enter Table #',
// style: TextStyle(
// color: AppColors.lightGrey,
// fontWeight: FontWeight.w500,
// fontSize: 14),
// ),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Styles.iconButtonWithShape(
Image.asset(
IMAGE_ASSET_DIR + 'location_icon.png',
height: 9,
color: dineIn ? AppColors.red : AppColors.orange,
),
// FaIcon(
// FontAwesomeIcons.locationArrow,
// color: dineIn ? AppColors.red : AppColors.orange,
// size: 12,
// ),
height: 22,
width: 22,
isCircle: true,
showShadow: false,
backgroundColor: dineIn
? AppColors.lightRed
: AppColors.lightOrange,
handler: () {}),
const SizedBox(
width: 6,
),
Text(
"5 KM",
style: TextStyle(
color: AppColors.lightGrey, fontSize: 12),
),
],
),
],
),
)
],
),
),
), // Add this code
);
}
#override
Widget? get flexibleSpace {
return ShaderMask(
// gradient layer ----------------------------
shaderCallback: (bound) {
return LinearGradient(
end: FractionalOffset.topCenter,
begin: FractionalOffset.bottomCenter,
colors: [
Colors.black.withOpacity(0.76),
Colors.black.withOpacity(0.66),
Colors.black26,
],
stops: [
0.0,
0.3,
0.45
]).createShader(bound);
},
blendMode: BlendMode.srcOver,
// your widget ------------------------
child: Container(
// constraints: const BoxConstraints(
// minWidth: 350,
// maxHeight: 350,
// ),
padding: EdgeInsets.all(10),
height: 350,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://media-cdn.tripadvisor.com/media/photo-s/1b/67/cc/f8/chestnut-restaurant.jpg'),
fit: BoxFit.cover),
)),
);
}
}

Incorrect use of parent data widget

i am getting error of "incorrect use of parent data widget" in debug console while clicking these buttons specifically error shows when clicking buttons..i am mentioning about the square buttons generated with List & Inkwell widget...pls help
class DetailsPage extends StatefulWidget {
#override
_DetailsPageState createState() => _DetailsPageState();
}
class _DetailsPageState extends State<DetailsPage> {
int isselected = -1;
int starvalue = 4;
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: double.maxFinite,
width: double.maxFinite,
child: Stack(children: [
Positioned(
child: Container(
width: double.maxFinite,
height: 360,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/mountain.jpeg',
),
fit: BoxFit.cover)),
)),
Positioned(
top: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
color: Colors.white,
),
],
)),
Positioned(
top: 270,
child: Container(
padding: EdgeInsets.only(left: 10, top: 20, right:10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
height: 430,
width: MediaQuery.of(context).size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ApplargeText(
text: 'Yesomi',
color: Colors.black.withOpacity(0.8),
),
AppText(
text: '250',
size: 20,
color: AppColors.mainColor,
)
],
),
SizedBox(
height: 10,
),
Row(
children: [
const Icon(Icons.location_on),
SizedBox(
width: 5,
),
AppText(
text: 'USA, California',
color: AppColors.mainColor,
size: 15)
],
),
SizedBox(
height: 10,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Wrap(
children: List.generate(
5,
(index) => Icon(Icons.star,
color: index < starvalue
? AppColors.starColor
: AppColors.textColor2)),
),
SizedBox(
width: 5,
),
AppText(
text: '4.0',
size: 12,
color: AppColors.mainColor,
),
],
),
SizedBox(
height: 15,
),
ApplargeText(
text: 'people',
color: Colors.black.withOpacity(0.8),
size: 25,
),
AppText(
text: 'Number of people in your group',
size: 15,
color: Colors.black26,
),
SizedBox(
height: 10,
),
Expanded(
child: Wrap(
children: List.generate(
5,
(index) => InkWell(
onTap: () {
setState(() {
isselected = index;
});
},
child: SquareButton(
size: 45,
isIcon: false,
iconn: Icons.search,
text: (index + 1).toString(),
textcolor: isselected == index
? Colors.white
: Colors.orange,
backgroundColor: isselected ==index
? Colors.black
: Colors.white,
),
))),
),
SizedBox(
height: 15,
),
ApplargeText(
text: 'Description',
color: Colors.black,
size: 25,
),
AppText(
text:
'Yesomi, the famed hill station of south India, is a romantic locale where natural beauty is everywhere to visit, explore and to enjoy.',
size: 12,
color: Colors.black,
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SquareButton(
iconn: Icons.favorite_border,
size: 50,
backgroundColor: Colors.white,
isIcon: true,
),
DefaultButtons(
width: 220,
text: 'Book now',
)
],
)
],
),
))
]),
),
);
}
}
// Squarebutton widget
enter code here
import 'package:flutter/material.dart';
import 'package:new_project/constants/appcolors.dart';
class SquareButton extends StatelessWidget {
final String? text;
final Color? textcolor;
final Color backgroundColor;
bool isIcon;
final IconData? iconn;
final Color? colorr;
double size;
SquareButton({
this.colorr,
this.text,
required this.size,
this.textcolor,
required this.backgroundColor,
this.isIcon = false,
this.iconn,
});
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 10, right: 10),
width: size,
height: size,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: backgroundColor,
border: Border.all(color: AppColors.mainColor, width:1.0)),
child: isIcon == false
? Center(
child: Text(
text.toString(),
style: TextStyle(
color: isIcon == false ? textcolor : Colors.white),
)): Icon(iconn));
}
}
You can't use Expanded inside Wrap widget.

NoSuchMethodError: Class 'List<Data> has no instance getter

I have gridviewbuilder that takes data from itemGriddata which has onTap function that directs it to a new page that takes data from that model as well but when I click on it the error in the title appears, any help or some kind of enlightement would be appreciated
this is gridview page
import 'package:flutter/material.dart';
import 'package:wild_wild_rift/builds/SinglePage.dart';
import 'package:wild_wild_rift/data/model.dart';
import 'package:google_fonts/google_fonts.dart';
class GridViewPage extends StatefulWidget {
#override
_GridViewPage createState() => _GridViewPage();
}
class _GridViewPage extends State<GridViewPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.grey,
automaticallyImplyLeading: true,
title: const Text(
'Champions',
style: TextStyle(
fontFamily: 'Lexend Doca',
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.bold,
),
),
elevation: 2,
),
body: Column(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(15, 15, 15, 15),
child: GridView.builder(
itemCount: itemGriddata.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
),
itemBuilder: (context, index) {
return GridSingleItem(
itemGriddata: itemGriddata[index],
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SinglePage(itemGriddata[index])));
},
);
},
),
),
),
],
));
}
}
class GridSingleItem extends StatelessWidget {
final itemGriddata;
final Function onTap;
const GridSingleItem({Key key, #required this.itemGriddata, this.onTap})
: super(key: key);
#override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: const Color(0xEEEEEE),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(itemGriddata.image).image,
),
boxShadow: const [
BoxShadow(
blurRadius: 3,
color: Color(0xDA000000),
)
],
borderRadius: BorderRadius.circular(9),
border: Border.all(
color: Colors.black,
),
),
child: Align(
alignment: AlignmentDirectional(-0.45, 0.85),
child: Text(
itemGriddata.name,
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Color(0xFFFFFCFC),
fontWeight: FontWeight.normal,
shadows: [
Shadow(
blurRadius: 8.0,
color: Colors.black,
offset: Offset(1.0, 1.0),
),
],
),
),
),
),
),
);
}
}
this is page that I'd want to take data
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import '../data/model.dart';
class SinglePage extends StatefulWidget {
#override
_SinglePage createState() => _SinglePage();
final Data data;
SinglePage(this.data);
}
class _SinglePage extends State<SinglePage> {
PageController pageViewController;
bool isFirstButton = false;
bool isSecondButton = false;
#override
void initState() {
super.initState();
pageViewController = PageController(initialPage: 0);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFF090F13),
automaticallyImplyLeading: true,
title: Text(
itemGriddata.name,
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.bold,
),
),
actions: const [],
centerTitle: false,
elevation: 2,
),
backgroundColor: const Color(0xFF262D34),
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0, 0, 0, 25),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Material(
color: Colors.transparent,
elevation: 3,
child: Container(
width: MediaQuery.of(context).size.width,
height: 150,
decoration: BoxDecoration(
color: const Color(0xFF090F13),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(
itemGriddata.backgroundimage,
).image,
),
),
),
),
],
),
Padding(
padding:
const EdgeInsetsDirectional.fromSTEB(20, 12, 20, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: const [
Text(
'Choose role',
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Color(0xFF8B97A2),
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
],
),
),
Padding(
padding:
const EdgeInsetsDirectional.fromSTEB(0, 12, 1, 0),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
16, 0, 0, 0),
child: InkWell(
onTap: () async {
isSecondButton = false;
isFirstButton = true;
setState(() {});
await pageViewController.animateToPage(
0,
duration: const Duration(milliseconds: 500),
curve: Curves.ease,
);
},
child: Material(
color: Colors.transparent,
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: const Color(0xFF090F13),
borderRadius: BorderRadius.circular(8),
shape: BoxShape.rectangle,
border: isFirstButton
? Border.all(color: Colors.white)
: null),
child: Stack(
children: [
Align(
alignment: const AlignmentDirectional(
0, -0.05),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
'assets/images/icon-position-jungle.png',
width: 50,
height: 50,
fit: BoxFit.cover,
),
const Padding(
padding: EdgeInsetsDirectional
.fromSTEB(0, 8, 0, 0),
child: AutoSizeText(
'BUILD 1',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Color(0xFF8B97A2),
fontSize: 14,
fontWeight:
FontWeight.normal,
),
),
),
],
),
),
],
),
),
),
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
16, 0, 0, 0),
child: Material(
color: Colors.transparent,
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: const Color(0xFF090F13),
borderRadius: BorderRadius.circular(8),
border: isSecondButton
? Border.all(color: Colors.white)
: null),
child: InkWell(
onTap: () async {
isSecondButton = true;
isFirstButton = false;
setState(() {});
await pageViewController.animateToPage(
1,
duration:
const Duration(milliseconds: 500),
curve: Curves.ease,
);
},
child: Stack(
children: [
Align(
alignment: const AlignmentDirectional(
0, -0.05),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
'assets/images/icon-position-jungle.png',
width: 50,
height: 50,
fit: BoxFit.cover,
),
const Padding(
padding: EdgeInsetsDirectional
.fromSTEB(0, 8, 0, 0),
child: AutoSizeText(
'BUILD 2',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Color(0xFF8B97A2),
fontSize: 14,
fontWeight:
FontWeight.normal,
),
),
),
],
),
),
],
),
),
),
),
),
],
),
),
),
Padding(
padding:
const EdgeInsetsDirectional.fromSTEB(20, 8, 20, 8),
child: Row(
mainAxisSize: MainAxisSize.max,
children: const [
Text(
'Builds',
style: TextStyle(
fontFamily: 'Lexend Deca',
color: Color(0xFF8B97A2),
fontSize: 14,
fontWeight: FontWeight.normal,
),
),
],
),
),
SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
16, 8, 16, 0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 200,
decoration: BoxDecoration(
color: const Color(0x00090F13),
boxShadow: const [
BoxShadow(
blurRadius: 3,
color: Colors.transparent,
offset: Offset(0, 2),
)
],
borderRadius: BorderRadius.circular(8),
),
child: SizedBox(
width: double.infinity,
height: 500,
child: PageView(
controller: pageViewController,
scrollDirection: Axis.horizontal,
children: [
Image.asset(
'assets/images/image_1.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
Image.asset(
'assets/images/image_2.png',
width: 100,
height: 100,
fit: BoxFit.scaleDown,
),
],
),
),
),
),
],
),
),
],
),
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(20, 0, 20, 8),
child: Row(
mainAxisSize: MainAxisSize.max,
children: const [
Text(
'Text',
style: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF8B97A2),
),
),
],
),
),
],
),
),
);
}
}
and this is the model with data
final dynamic itemGriddata = [
Data(
name: "Ahri",
image: "assets/images/Ahri.png",
backgroundimage: "assets/images/Ahri_0.jpg"),
Data(
name: "Akali",
image: "assets/images/Akali.png",
backgroundimage: "assets/images/Akali_0.jpg")
];
class Data {
final String name;
final String image;
final String backgroundimage;
Data({this.name, this.image, this.backgroundimage});
}
The issue is that your SinglePage widget has a prop named final Data data; but the _SinglePageState widget is calling itemGriddata for your title and images. You'll need to change your code like so:
class SinglePage extends StatefulWidget {
const SinglePage(Key? key, this.data): super(key: key);
final Data data;
#override
State<StatefulWidget> createState() => _SinglePageState();
}
class _SinglePageState extends State<SinglePage> {
// use widget.data to get name, image, and backgroundImage
// ex... widget.data.name or widget.data.image
#override
Widget build(BuildContext context) {
return Text(widget.data.name);
}
}
You're passing the data correctly to SinglePage, but just change a few lines to ensure you're calling something with actual data! :D