No TabController for TabBarView in flutter - flutter

Here is my code
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:responsive_widgets/responsive_widgets.dart';
import 'package:pie_chart/pie_chart.dart';
import 'dart:io';
import 'package:flutter/foundation.dart';
class Recipe extends StatefulWidget {
#override
_RecipeState createState() => _RecipeState();
}
class _RecipeState extends State<Recipe> {
TabController _tabController;
bool toggle = false;
Color selectedColor1 = Color(0xffff718b);
Color selectedColor2 = Colors.black;
Color cc = Color(0xffff718b);
Map<String, double> dataMap = Map();
List<Color> colorList = [
Color(0xFFFFBD4B),
Color(0xFF55CCD4),
];
#override
void initState() {
super.initState();
dataMap.putIfAbsent("Leftover Ingredients", () => 75);
dataMap.putIfAbsent("Used Ingredients", () => 25);
}
#override
Widget build(BuildContext context) {
ResponsiveWidgets.init(
context,
height: 1920, // Optional
width: 1080, // Optional
allowFontScaling: true, // Optional
);
return ResponsiveWidgets.builder(
height: 1920, // Optional
width: 1080, // Optional
allowFontScaling: true,
child: SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: TextResponsive(
"Recipe",
style: TextStyle(
fontFamily: 'SofiaPro-SemiBold',
fontSize: 50,
color: Color(0xff130f10),
),
),
centerTitle: true,
),
body: Padding(
padding: EdgeInsets.all(10.0),
child: ListView(
shrinkWrap: true,
children: <Widget>[
Container(
height: 450.h,
child: Stack(
children: <Widget>[
Positioned(
top: -5,
left: 20,
child: Image.asset(
'Assets/recipe_details/Place Your Image Here.png',
height: 454.h,
width: 953.w,
),
),
// Adobe XD layer: 'Place Your Image He…' (group)
Positioned(
top: -10,
left: 840.w,
child: Image.asset(
'Assets/recipe_details/Place Your Image Here.png',
height: 454.h,
width: 953.w,
),
),
Positioned(
left: 30,
child: Image.asset(
'Assets/recipe_details/Place Your Image Here (Double Click to Edit)-1.png',
height: 363.h,
width: 888.w,
),
),
Positioned(
child: Image.asset(
'Assets/recipe_details/Vector Smart Object (Double Click To Edit).png'),
),
Positioned(
top: -30,
left: 100,
child: Image.asset(
'Assets/recipe_details/Place Your Image Here (Double Click to Edit).png',
width: 145,
height: 176,
),
),
Align(
child: Image.asset(
'Assets/recipe_details/kisspng-pizza-margherita-bacon-delivery-cheese-pizza-menu-5b2597bcabaf52.8918615115291903327032.png',
),
),
],
),
),
SizedBox(
height: 8,
),
Center(
child: TextResponsive(
'Tomotto pizza',
style: TextStyle(
fontFamily: 'SofiaPro-Bold',
fontSize: 75,
color: const Color(0xff130f10),
height: 0.8,
),
textAlign: TextAlign.left,
),
),
SizedBox(
height: 5,
),
Center(
child: TextResponsive(
'35 - 40Minutes',
style: TextStyle(
fontFamily: 'SofiaPro-Medium',
fontSize: 40,
color: const Color(0x80282828),
),
textAlign: TextAlign.left,
),
),
SizedBox(
height: 20,
),
DefaultTabController(
initialIndex: 0,
// The number of tabs / content sections to display.
length: 2,
child: TabBar(
controller: _tabController,
tabs: [
Tab(
child: Container(
width: 502.5.w,
height: 157.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
),
color: Color(0xfffffafb),
),
child: Center(
child: TextResponsive(
'Ingrediants',
style: TextStyle(
fontFamily: 'SofiaPro-SemiBold',
fontSize: 50,
color: selectedColor1,
),
),
),
),
),
Tab(
child: Container(
width: 502.5.w,
height: 157.h,
child: Center(
child: TextResponsive(
'Method',
style: TextStyle(
fontFamily: 'SofiaPro-SemiBold',
fontSize: 50,
color: selectedColor2,
),
),
),
),
),
],
), // Complete this code in the next step.
),
TabBarView(
children: [Text("data"), Text("data2")],
controller: _tabController,
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleAvatar(
backgroundColor: Colors.white,
radius: 10,
),
SizedBox(
width: 20,
),
TextResponsive(
'Keep track my leftovers',
style: TextStyle(
fontFamily: 'SofiaPro-Light',
fontSize: 40,
color: const Color(0xb3130f10),
height: 1.5,
),
textAlign: TextAlign.left,
),
],
),
// Adobe XD layer: 'Rectangle 7 copy 21' (shape)
SizedBox(
height: 15,
),
Center(
child: Container(
width: 800.w,
height: 140.0.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffff718b),
),
child: Center(
child: TextResponsive(
'Add to menu',
style: TextStyle(
fontFamily: 'SofiaPro-SemiBold',
fontSize: 45,
color: const Color(0xffffffff),
),
textAlign: TextAlign.center,
),
),
),
),
SizedBox(
height: 15,
),
Divider(
thickness: 1,
),
Padding(
padding: EdgeInsets.all(20.0),
child: TextResponsive(
'Price Breakdown',
style: TextStyle(
fontFamily: 'SofiaPro-SemiBold',
fontSize: 55,
color: const Color(0xff130f10),
),
textAlign: TextAlign.left,
),
),
Container(
child: Center(
child: PieChart(
dataMap: dataMap,
animationDuration: Duration(milliseconds: 800),
chartLegendSpacing: 32.0,
chartRadius: MediaQuery.of(context).size.width / 2.7,
showChartValuesInPercentage: true,
showChartValues: true,
showChartValuesOutside: true,
chartValueBackgroundColor: Colors.white,
colorList: colorList,
showLegends: true,
legendPosition: LegendPosition.right,
decimalPlaces: 1,
showChartValueLabel: true,
initialAngle: 0,
chartValueStyle: defaultChartValueStyle.copyWith(
color: Colors.blueGrey[900].withOpacity(0.9),
),
chartType: ChartType.ring,
)),
),
],
),
),
),
),
);
}
}
class Ing extends StatelessWidget {
final Color color;
final String string;
final String data;
Ing({this.string, this.color, this.data});
#override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
// Adobe XD layer: 'Rectangle 9' (shape)
Container(
width: 25.0.h,
height: 25.0.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.elliptical(12.5, 12.5)),
color: color,
),
),
SizedBox(
width: 10,
),
TextResponsive(
string,
style: TextStyle(
fontFamily: 'SofiaPro',
fontSize: 45,
color: const Color(0xff130f10),
height: 1.3333333333333333,
),
textAlign: TextAlign.left,
),
],
),
TextResponsive(
data,
style: TextStyle(
fontFamily: 'SofiaPro-Medium',
fontSize: 45,
color: const Color(0xcc130f10),
height: 1.3333333333333333,
),
textAlign: TextAlign.left,
),
],
),
);
}
}
Error
The relevant error-causing widget was
Scaffold
lib\recipe_details_5.dart:45
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#cbb99 relayoutBoundary=up2 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was
Padding
lib\recipe_details_5.dart:62
════════════════════════════════════════════════════════════════════════════════
W/ActivityThread(18947): SCHED: com.project01withsauiux/.MainActivity [70, r=39ms, a=16ms, w=79911ms]

See the code below, it may help you:
class _RecipeState extends State<Recipe> with SingleTickerProviderStateMixin{//changed
TabController _tabController;
...
#override
void initState() {
super.initState();
dataMap.putIfAbsent("Leftover Ingredients", () => 75);
dataMap.putIfAbsent("Used Ingredients", () => 25);
_tabController = TabController(length: 2, vsync: this, initialIndex: 0);//changed
}
...

Related

Making a Phone Dialer App. How to link a FloatingActionButton such that it opens a textfield where I can enter a Number

I have tried making a function that returns a TextField and then putting the function name in the onPressed argument. However when I do press the button nothing happens even in the terminal other than acknowledging that the button has been pressed.
I am only a week or so in flutter learning and entirely new to stackoverflow so please forgive if I am stupid.This is my code:-
import 'package:flutter/material.dart';
void main() {
runApp(
dialer(),
);
}
class dialer extends StatefulWidget {
const dialer({super.key});
#override
State<dialer> createState() => _dialerState();
}
txtfld(onPressed) {
return Container(
child: TextField(
keyboardType: TextInputType.phone,
),
);
}
class _dialerState extends State<dialer> {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.black,
actions: <Widget>[
Icon(
Icons.search,
size: 30,
),
Icon(
Icons.more_vert,
size: 30,
),
Padding(
padding: EdgeInsets.all(5),
),
],
),
body: Column(
children: <Widget>[
Flexible(
flex: 3,
fit: FlexFit.tight,
child: Container(
margin: EdgeInsets.only(top: 50),
child: Text(
'Phone',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Container(),
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'94693-68171',
style: TextStyle(
color: Colors.grey,
),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(),
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'696969696969',
style: TextStyle(color: Colors.grey),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'4204204204',
style: TextStyle(color: Colors.grey),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'6666666666',
style: TextStyle(color: Colors.grey),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'1234567890',
style: TextStyle(color: Colors.grey),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
height: 80,
width: 314,
color: Color.fromARGB(255, 59, 59, 59),
padding: EdgeInsets.all(10),
child: Text(
'Elon musk',
style: TextStyle(color: Colors.grey),
textScaleFactor: 1.25,
),
),
],
),
SizedBox(
height: 5,
),
],
),
],
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.call),
onPressed: (() => txtfld),
elevation: 12,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
),
);
}
}
Try this : Define a focus node for your textfield and remember to dispose it once triggered by the onTap as below
late FocusNode commentFocus;
#override
void dispose() {
commentFocus.dispose();
}
#override
initState(){
commentFocus = FocusNode();
super.initState();
}
...
txtfld(onPressed) {
return Container(
child: TextField(
focusNode: commentFocus,
keyboardType: TextInputType.phone,
),
);
}
...
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.call),
onPressed: (){
commentFocus.requestFocus();///Trigger here.
},
elevation: 12,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,

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

flutter issue: bottom overflowed by 57 pixels

Here my bottom preferredSize (preferredSize: Size.fromHeight(148.0)) in appBar.
This error raised onlu in IOS not in android. I dont know why?
On every tab this error raising, so I thought I got this error by preferredSize.
But how to solve this I am not understanding.
This error raised onlu in IOS not in android. I dont know why?
On every tab this error raising, so I thought I got this error by preferredSize.
But how to solve this I am not understanding.
this is my code
import 'package:flutter/material.dart';
import 'package:showcaseview/showcaseview.dart';
import 'package:url_launcher/url_launcher.dart' as UrlLauncher;
import 'package:dropdown_button2/dropdown_button2.dart';
import 'dart:developer';
import '../../../APIMnager/APIManager.dart';
import '../../../APIMnager/preferences.dart';
import '../../../Constants/constants.dart';
import 'action_page.dart';
import 'holding_page.dart';
import 'overview_page.dart';
import 'report_page.dart';
class PMSListDataPage extends StatelessWidget {
final panNum;
final singlePMSData;
final allPMSListData;
const PMSListDataPage(
{Key? key, this.panNum, this.singlePMSData, this.allPMSListData})
: super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: ShowCaseWidget(
onStart: (index, key) {
log('onStart: $index, $key');
},
onComplete: (index, key) {
log('onComplete: $index, $key');
print("here me");
if (index == 0) {
Preferences.saveData("showCaseCount2", "2");
}
},
blurValue: 1,
builder: Builder(
builder: (context) => PMSListDataPage1(
panNum: panNum,
singlePMSData: singlePMSData,
allPMSListData: allPMSListData)),
autoPlayDelay: const Duration(seconds: 3),
),
);
}
}
class PMSListDataPage1 extends StatefulWidget {
final panNum;
final singlePMSData;
final allPMSListData;
const PMSListDataPage1(
{Key? key, this.panNum, this.singlePMSData, this.allPMSListData})
: super(key: key);
#override
_PMSListDataPage1State createState() => _PMSListDataPage1State();
}
class _PMSListDataPage1State extends State<PMSListDataPage1> {
var selectedValue;
ApiManager apiManager = ApiManager();
final GlobalKey _one = GlobalKey();
final GlobalKey _two = GlobalKey();
final GlobalKey _three = GlobalKey();
final scrollController = ScrollController();
#override
void initState() {
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: DefaultTabController(
length: 4,
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: Icon(Icons.arrow_back_ios_rounded),
onPressed: () {
Navigator.pop(context);
},
tooltip: '',
);
},
),
elevation: 0,
backgroundColor: skyBlue,
title: Text(
"PMS",
style: TextStyle(fontSize: tSize16),
),
actions: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
icon: Image.asset(
"assets/phone_icon.png",
height: 25,
width: 25,
),
onPressed: () {
UrlLauncher.launch('tel:+91$UserRMNumber');
}))
],
)
],
bottom: PreferredSize(
preferredSize: Size.fromHeight(148.0),
child: Column(
children: [
Container(
color: skyBlue,
height: 90,
child:
nameView(widget.singlePMSData, widget.allPMSListData),
),
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: TabBar(
overlayColor:
MaterialStateProperty.all(Colors.transparent),
indicatorColor: Colors.white,
unselectedLabelColor: lightBlue,
onTap: (v) {
searchHoldingsQuery.clear();
FocusScope.of(context).unfocus();
},
indicator: UnderlineTabIndicator(
borderSide: BorderSide(
color: Colors.white,
width: 3.2,
style: BorderStyle.solid),
insets: EdgeInsets.only(left: 30.0, right: 30)),
isScrollable: true,
labelColor: Colors.white,
tabs: [
Tab(
child: Text(
'OVERVIEW',
),
),
Tab(
child: Text(
'HOLDINGS',
),
),
Tab(
child: Text(
'REPORTS',
),
),
Tab(
child: Text(
'ACTIONS',
),
),
],
),
),
],
),
),
),
body:
TabBarView(physics: NeverScrollableScrollPhysics(), children: [
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: OverviewPage(),
),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: HoldingPage(),
),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: ReportPage(),
),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: ActionPage(),
),
]),
)),
);
}
}
extension WidgetExtension on _PMSListDataPage1State {
nameView(singlePMSData, allPMSListData) {
return Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 5, bottom: 0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
),
child: DropdownButtonHideUnderline(
child: DropdownButton2(
onMenuClose: () {},
onTap: () {},
isExpanded: true,
hint: Row(
children: [
SizedBox(
width: 10,
),
Expanded(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
singlePMSData['name'].toString(),
style: TextStyle(
fontSize: tSize16,
fontWeight: FontWeight.w600,
color: blackColor,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 6,
),
Row(
children: [
Text(
'₹ ${singlePMSData["current_value"]}',
style: TextStyle(
fontSize: tSize16,
fontWeight: FontWeight.w600,
color: green2Color,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(
width: 10,
),
],
),
],
),
],
),
),
],
),
items: allPMSListData.map<DropdownMenuItem<Object>>((option) {
return DropdownMenuItem(
value: option,
child: Container(
width: double.infinity,
alignment: Alignment.centerLeft,
// padding: const EdgeInsets.fromLTRB(0,8.0,0,6.0),
child: Row(
children: [
SizedBox(
width: 10,
),
Text(
option["name"],
style: TextStyle(
fontSize: tSize16,
fontWeight: FontWeight.w600,
color: blackColor,
),
overflow: TextOverflow.ellipsis,
),
],
),
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: lightGreyColor, width: 1)))),
);
}).toList(),
selectedItemBuilder: (con) {
return allPMSListData.map<Widget>((item) {
return Row(
children: [
SizedBox(
width: 10,
),
Expanded(
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['name'].toString(),
style: TextStyle(
fontSize: tSize16,
fontWeight: FontWeight.w600,
color: blackColor,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 6,
),
Row(
children: [
Text(
"₹ ${item["current_value"]}",
style: TextStyle(
fontSize: tSize16,
fontWeight: FontWeight.w600,
color: green2Color,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(
width: 10,
),
],
),
],
),
],
),
),
],
);
}).toList();
},
value: selectedValue,
onChanged: (dynamic value) {
setState(() {
});
},
icon: Container(
width: 22,
height: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
color: skyBlue,
),
child: Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
size: 17,
),
),
iconOnClick: Container(
width: 22,
height: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
color: skyBlue,
),
child: Icon(
Icons.keyboard_arrow_up,
color: Colors.white,
size: 17,
),
),
iconSize: 14,
buttonHeight: 70,
buttonPadding: const EdgeInsets.only(left: 14, right: 14),
buttonDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: lightBlue,
),
color: Colors.white,
),
buttonElevation: 1,
itemHeight: 44,
itemPadding: const EdgeInsets.only(left: 14, right: 14),
dropdownMaxHeight: 200,
dropdownPadding: null,
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
color: Colors.white,
),
dropdownElevation: 1,
scrollbarRadius: const Radius.circular(40),
scrollbarThickness: 3,
scrollbarAlwaysShow: false,
// offset: const Offset(-10, 0),
),
),
),
);
}
}

SingleChildScrollView not working on the full row

I'm having a Row which contains a list of widgets , a Builder and a variable that adds new item to the list to be built with the Builder.
Anyway , I was trying to wrap the whole Rows with SingleChildScrollView , but now , every part of my Row is scrolling separately .
My Row contains two widgets Expanded() and inside the Expanded() , I got a itemBuilder.
I got a button in the bottom that calls two functions , and they will add new Widgets to the List.
class _ajouterUnDocumentState extends State<ajouterUnDocument> {
List<Widget> _cardList = [
(InputRefNomProduit()),
];
List<Widget> _cardList2 = [
(InputQuntitePrixProduit()),
];
void _addCardWidgetExp1() {
setState(() {
_cardList.add(SizedBox(height: 10));
_cardList.add(InputRefNomProduit());
});
}
void _addCardWidgetExp2() {
setState(() {
_cardList2.add(SizedBox(height: 10));
_cardList2.add(InputQuntitePrixProduit());
});
}
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFF2A2D3E),
body: Padding(
padding:
EdgeInsets.only(top: 60.0, bottom: 60.0, left: 120.0, right: 120.0),
child: Form(
key: _formKey,
child: Card(
shadowColor: Color.fromARGB(255, 255, 255, 255),
color: Color(0xFF2A2D3E),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0)),
elevation: 10.0,
child: Container(
width: 1800,
child: Column(
children: <Widget>[
Center(
child: Container(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
Text(
"AJOUTER UN FOURNISSEUR",
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.bold),
),
Divider(
thickness: 3,
),
SingleChildScrollView(
child: Container(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
flex: 3,
child: Column(
children: [
SizedBox(
height: 10,
),
SizedBox(
height: 530,
width: 500,
child: ListView.builder(
itemCount: _cardList.length,
itemBuilder: (context, index) {
return _cardList[index];
}),
),
],
),
),
SizedBox(width: 25),
Expanded(
flex: 3,
child: Column(
children: [
SizedBox(
height: 10,
),
SizedBox(
height: 530,
width: 500,
child: ListView.builder(
itemCount: _cardList2.length,
itemBuilder: (context, index) {
return _cardList2[index];
}),
),
],
),
),
],
),
),
),
//Membership Widget from the widgets folder
Center(
child: Row(
children: <Widget>[
SizedBox(
width: 400.0,
),
MaterialButton(
color: Colors.grey[200],
onPressed: () {},
child: Text(
"Annuler",
style: TextStyle(color: Colors.black),
),
),
SizedBox(
width: 20.0,
),
MaterialButton(
color: Color.fromARGB(255, 75, 100, 211),
onPressed: () {
_addCardWidgetExp1();
_addCardWidgetExp2();
},
child: Text(
"Ajouter",
style: TextStyle(color: Colors.white),
),
),
],
),
),
],
),
),
),
],
),
),
),
),
),
);
}
}
This is InputQuntitePrixProduit():
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
width: 25.0,
child: Text(
"$label",
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w900,
color: Color.fromARGB(255, 255, 255, 255),
),
),
),
),
Expanded(
flex: 3,
child: Container(
width: MediaQuery.of(context).size.width / 3.7,
color: Color.fromARGB(255, 255, 255, 255),
child: TextFormField(
controller: fieldController,
validator: fieldValidator,
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
hintText: "$content",
hintStyle: TextStyle(
color: Color.fromARGB(255, 190, 190, 190),
fontSize: 14),
fillColor: Color.fromARGB(255, 0, 0, 0),
),
),
),
),
SizedBox(
width: 5.0,
),
Expanded(
flex: 2,
child: Container(
width: 50.0,
child: Text(
"$label2",
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w900,
color: Color.fromARGB(255, 255, 255, 255),
),
),
),
),
SizedBox(
width: 5.0,
),
Expanded(
flex: 3,
child: Container(
width: MediaQuery.of(context).size.width / 3.7,
color: Color.fromARGB(255, 255, 255, 255),
child: TextFormField(
enabled: false,
controller: fieldController,
validator: fieldValidator,
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
hintText: "$content2",
hintStyle: TextStyle(
color: Color.fromARGB(255, 190, 190, 190),
fontSize: 14),
fillColor: Color.fromARGB(255, 0, 0, 0),
),
),
),
),
],
);
},
);
}
}

Flutter IconButton Remove Padding on Left to Align with Title Texts

So far it just goes in the middle even with a padding Edge Inset set to zero and Box Constraints.
Row(children: [
Padding(
padding: const EdgeInsets.fromLTRB(
3, 3, 3, 6),
child: Container(
width: 150,
height: 30,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Title Sub-title",
textAlign: TextAlign.left,
maxLines: 2,
style: TextStyle(
height: 1.2,
fontFamily:
'Roboto’,
fontSize: 12,
letterSpacing: 0.15,
color: Colors.black,
),
),
),
),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
0, 10, 0, 3),
),
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
onPressed: () {},
icon: Icon(
Icons.bookmark_border,
size: 20.0,
color: Colors.black,
),
),
Text(
"Author",
textAlign: TextAlign.left,
style: TextStyle(
height: 1.1,
fontFamily: 'Roboto Light',
fontSize: 8,
color: Colors.black,
),
),
],
),
],
),
),
),
],
),
Try with column tree and adjust your padding as you desire
import 'package:flutter/material.dart';
import 'package:so_test/screen/child_page.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
// This widget is the root of your application.
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool visible = true;
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text("Test obviously"),
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.green,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 3, 0),
child: Container(
width: 150,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Title",
textAlign: TextAlign.left,
maxLines: 2,
style: TextStyle(
height: 1.2,
fontSize: 12,
letterSpacing: 0.15,
color: Colors.black,
),
),
),
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 3, 0),
width: 150,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Sub Title",
textAlign: TextAlign.left,
maxLines: 2,
style: TextStyle(
height: 1.2,
fontSize: 12,
letterSpacing: 0.15,
color: Colors.black,
),
),
),
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 5,
),
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
onPressed: () {},
icon: Icon(
Icons.bookmark_border,
size: 20.0,
color: Colors.black,
),
),
Text(
"Author",
textAlign: TextAlign.left,
style: TextStyle(
height: 1.1,
fontFamily: 'Roboto Light',
fontSize: 8,
color: Colors.black,
),
),
],
),
],
),
),
));
}
}
Output:
You can keep the first Container in different column and create the separate column for below three children's.