I have a problem this that in my android device cwctv page is working but in IOS Device giving height error,so how to set height for every device.
I have a problem this that in my android device cwctv page is working but in IOS Device giving height error,so how to set height for every device.
I have a problem this that in my android device cwctv page is working but in IOS Device giving height error,so how to set height for every device.
this is my cwctv page.
#override
Widget build(BuildContext context) {
return Scaffold(backgroundColor: Colors.white,
resizeToAvoidBottomInset: false,
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
automaticallyImplyLeading: true,
backgroundColor: Colors.white,
elevation: 0.5, ),
drawer: Drawer(
child: SideBar(),
),
floatingActionButton: Padding(
padding: const EdgeInsets.only(top: 18.0),
child: Container(
height: 80,
width: 80,
child: FittedBox(
child: FloatingActionButton(
focusColor: Colors.transparent,
backgroundColor: selectBlueColor,
onPressed: () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => HomePage()));
},
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: Image.asset(
'assets/home_icon.png',
),
elevation: 1.0,
highlightElevation: 2,
),
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: Container(
// height: MediaQuery.of(context).size.height * (10 / 100),
child: BottomNavBarTV()),
body: Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 16.0,right: 16,bottom: 4,top: 0),
child: SizedBox(
height: 60,
child: TextField( keyboardType: TextInputType.text,
onChanged: (value) {
setState(() {
print("tab on cwctv page $cwcTvTab");
});
},
// controller: cwcTvTab == 3 ?searchImageQuery : cwcTvTab == 2 ?searchPdfQuery : cwcTvTab == 1 ? searchAudioQuery : searchVideoQuery,
controller: searchQuery,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide.none,
),
filled: true,
fillColor: const Color(0xFFF1F2F6),
hintText: 'Search for Wellness Tips & Tricks',
suffixIcon: const Icon(
Icons.search_outlined,
color: Color(0xFF444444),
),
),
)
)),
Padding(
padding: EdgeInsets.only(top: 70.0),
child: TestScreen(widget.selectTab),
),
// CwcTVPageChanger(),
// VideoComponent(),
],
),
);
}
This is my tab screen page.
import 'package:cwc/constants/constants.dart';
import 'package:cwc/ui/CwcTv/components/images/image_document.dart';
import 'package:cwc/ui/CwcTv/components/podcast/podcast_list.dart';
import 'package:cwc/ui/CwcTv/components/slides/slide_component.dart';
import 'package:cwc/ui/CwcTv/components/videos/video_component.dart';
import 'package:cwc/ui/CwcTv/cwc_tv.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:cwc/constants/constant_functions.dart';
class TestScreen extends StatefulWidget {
int selectedPage;
TestScreen(this.selectedPage);
#override
State<TestScreen> createState() => _TestScreenState();
}
class _TestScreenState extends State<TestScreen> with SingleTickerProviderStateMixin, WidgetsBindingObserver {
void _handleTabSelection() {
setState(() {});
}
#override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
// _tabSection(context, widget.selectedPage,controller!),
_tabSection(context, widget.selectedPage),
],
);
}
}
Widget _tabSection(BuildContext context, var selectedPage) {
return DefaultTabController(
initialIndex: selectedPage,
length: 4,
child: SafeArea(
child: Column(
// mainAxisSize: MainAxisSize.min,
children: [
TabBar(
indicatorColor: Colors.black,
onTap: (v) {
cwcTvTab = v;
},
isScrollable: true,
// physics: NeverScrollableScrollPhysics(),
labelColor: Colors.black,
tabs: [
Tab(
child: Text(
'Video',
style: GoogleFonts.poppins(color: Colors.black),
),
),
Tab(
child: Text(
'Podcast',
style: GoogleFonts.poppins(color: Colors.black),
),
),
Tab(
child: Text(
'Documents',
style: GoogleFonts.poppins(
color: Colors.black,
),
),
),
Tab(
child: Text(
'Images',
style: GoogleFonts.poppins(color: Colors.black),
),
),
],
),
Container(
height: MediaQuery.of(context).size.height - 282,
// height: MediaQuery.of(context).size.height - 205,
// height: double.infinity,
child:
TabBarView( physics: NeverScrollableScrollPhysics(),
children: [
VideoComponent(),
PodcastList(),
SlideComponent(),
ImageDocument(),
]),
),
],
),
),
);
}
this is my android Device's screenshot.
this is my IOS Device's screenshot.
There is 2 options you can use, first try with indicator like this one:
TabBar(
indicator: UnderlineTabIndicator(
borderSide: BorderSide(width: 5.0),
insets: EdgeInsets.symmetric(horizontal:16.0)
),
indicatorColor: Colors.black,
onTap: (v) {
cwcTvTab = v;
},
isScrollable: true,
// physics: NeverScrollableScrollPhysics(),
labelColor: Colors.black,
tabs: [
Tab(
child: Text(
'Video',
style: GoogleFonts.poppins(color: Colors.black),
),
),
Tab(
child: Text(
'Podcast',
style: GoogleFonts.poppins(color: Colors.black),
),
),
Tab(
child: Text(
'Documents',
style: GoogleFonts.poppins(
color: Colors.black,
),
),
),
Tab(
child: Text(
'Images',
style: GoogleFonts.poppins(color: Colors.black),
),
),
],
),
Or you can just wrap it with a container.
PreferredSize(
preferredSize: const Size.fromHeight(10),
child: Container(
height: 50,
child: TabBar(
indicatorColor: Colors.black,
isScrollable: true,
labelColor: Colors.black,
tabs: [
Tab(
child: Text(
'Video',
),
),
Tab(
child: Text(
'Podcast',
),
),
Tab(
child: Text(
'Documents',
),
),
Tab(
child: Text(
'Images',
),
),
],
),
),
),
Related
I have a problem. I would like to use emoji_picker_flutter. This should be displayed under the TextInputField but is not displayed. What is the reason for this? Do I have to implement it differently or what is the reason? I tried to add the Config, but it did not change anything.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:flutter/foundation.dart' as foundation;
import '../Model/ChatModel.dart';
class IndidivdualPage extends StatefulWidget {
final ChatModel chatModel;
const IndidivdualPage({Key? key, required this.chatModel}) : super(key: key);
#override
_IndividualPageState createState() => _IndividualPageState();
}
class _IndividualPageState extends State<IndidivdualPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
leadingWidth: 70,
titleSpacing: 0,
leading: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.arrow_back, size: 24,),
CircleAvatar(
child: SvgPicture.asset(widget.chatModel.isGroup ? "assets/account-group.svg" : "assets/account.svg",
color: Colors.white, height: 34, width: 34),
radius: 20,
backgroundColor: Colors.lightBlue,
),
],
),
),
title: InkWell(
onTap: () {},
child: Container(
margin: EdgeInsets.all(6),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.chatModel.name, style: TextStyle(
fontSize: 18.5,
fontWeight: FontWeight.bold
),),
Text("last seend today at 15:03", style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal
),)
],
),
),
),
actions: [
IconButton(onPressed: () {}, icon: Icon(Icons.videocam)),
IconButton(onPressed: () {}, icon: Icon(Icons.call)),
PopupMenuButton<String>(
onSelected: (value){
print(value);
},
itemBuilder: (BuildContext context){
return [
PopupMenuItem(child: Text("View Contact"), value:"View Contact",),
];
})
],
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
ListView(),
Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
children: [
Container(
width: MediaQuery.of(context).size.width - 60,
child:
Card(
margin: EdgeInsets.only(left: 2, right: 2, bottom: 8),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
child: TextFormField(
textAlignVertical: TextAlignVertical.center,
keyboardType: TextInputType.multiline,
maxLines: 5,
minLines: 1,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Send a message",
prefixIcon: IconButton(icon: Icon(Icons.emoji_emotions), onPressed: () { },),
suffixIcon: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(onPressed: () {}, icon: Icon(Icons.attach_file)),
IconButton(onPressed: () {}, icon: Icon(Icons.camera_alt)),
],
),
contentPadding: EdgeInsets.all(5),
),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8, right: 5, left: 2),
child: CircleAvatar(
radius: 25,
backgroundColor: Colors.lightBlue,
child: IconButton(icon: Icon(Icons.mic),color: Colors.white, onPressed: () {},),
),
),
],
),
emojiSelect(),
],
)
)
],
),
),
);
}
Widget emojiSelect() {
return EmojiPicker(
onEmojiSelected: (Category? category, Emoji? emoji) {
print(emoji);
},
onBackspacePressed: () {
// Do something when the user taps the backspace button (optional)
}, // pass here the same [TextEditingController] that is connected to your input field, usually a [TextFormField]
config: Config(
columns: 7,
emojiSizeMax: 32 * (Platform.isIOS ? 1.30 : 1.0), // Issue: https://github.com/flutter/flutter/issues/28894
verticalSpacing: 0,
horizontalSpacing: 0,
gridPadding: EdgeInsets.zero,
initCategory: Category.RECENT,
bgColor: Color(0xFFF2F2F2),
indicatorColor: Colors.blue,
iconColor: Colors.grey,
iconColorSelected: Colors.blue,
backspaceColor: Colors.blue,
skinToneDialogBgColor: Colors.white,
skinToneIndicatorColor: Colors.grey,
enableSkinTones: true,
showRecentsTab: true,
recentsLimit: 28,
noRecents: const Text(
'No Recents',
style: TextStyle(fontSize: 20, color: Colors.black26),
textAlign: TextAlign.center,
), // Needs to be const Widget
loadingIndicator: const SizedBox.shrink(), // Needs to be const Widget
tabIndicatorAnimDuration: kTabScrollDuration,
categoryIcons: const CategoryIcons(),
buttonMode: ButtonMode.MATERIAL,
),
);
}
}
you need to set height for your emojiSelect like this:
SizedBox(height: 300, child: emojiSelect()),
So there are multiple errors shown when you try to run your code. If you scroll to the top there are a lot of indicators that something is wrong with the height of the view.
If you check the example provided within the library, you can see that the author wrapped the EmojiPicker with SizedBox.
If you do something similar to:
child: SizedBox(height: 250, child: EmojiPicker(...),)
it should help.
I am developing a social media app with flutter.
I want to create a screen where users can post new posts, the user will select multi images and videos (10 max), specify the location and write a post caption.
I want to know how to move this bar that contains my action buttons upwards whenever the keyboard is triggered.
besides, I want to add the selected images at the bottom also
so how to do that?
here is the UI I want to approach.
this is what I've done so far
here is the code of the new_post_screen.dart file
import 'package:flutter/material.dart';
import '../widgets/profile_avatar.dart';
class NewPostScreen extends StatefulWidget {
const NewPostScreen({super.key});
static const routeName = '/new-post';
#override
State<NewPostScreen> createState() => _NewPostScreenState();
}
class _NewPostScreenState extends State<NewPostScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text('New Post'),
leading: TextButton(
child: Text(
'Cancel',
style: Theme.of(context).textTheme.headline6!.copyWith(
color: Theme.of(context).primaryColor,
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
leadingWidth: 80,
actions: [
Container(
margin: const EdgeInsets.all(10),
child: TextButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).primaryColor)),
child: const Text(
'Post',
style: TextStyle(color: Colors.white),
),
),
)
],
),
body: SingleChildScrollView(
child: Column(
children: const [
_PostHeader(),
Card(
elevation: 0,
child: Padding(
padding: EdgeInsets.all(8.0),
child: TextField(
maxLines: null,
autofocus: true,
decoration:
InputDecoration.collapsed(hintText: "Type a memory..."),
),
)),
],
),
),
floatingActionButton: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey[200],
),
child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [
IconButton(onPressed: () {}, icon: const Icon(Icons.image)),
IconButton(onPressed: () {}, icon: const Icon(Icons.location_on))
]),
),
);
}
}
class _PostHeader extends StatelessWidget {
const _PostHeader({
Key? key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
child: Row(
children: [
const ProfileAvatar(
imageUrl: 'https://picsum.photos/200',
),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Username', style: Theme.of(context).textTheme.headline6),
const SizedBox(height: 5),
SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
child: DropdownButtonFormField(
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 2),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 1, color: Theme.of(context).primaryColor),
borderRadius:
const BorderRadius.all(Radius.circular(8)),
),
filled: true,
fillColor: Theme.of(context).backgroundColor,
),
icon: const Icon(
Icons.keyboard_arrow_down,
size: 15,
color: Colors.white,
),
items: [
DropdownMenuItem(
value: 'Public',
child: Row(
children: [
const Icon(
Icons.public,
size: 15,
color: Colors.white,
),
const SizedBox(width: 5),
Text('Public',
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: Colors.white)),
],
),
),
DropdownMenuItem(
value: 'Private',
child: Row(
children: [
const Icon(
Icons.lock,
size: 15,
color: Colors.white,
),
const SizedBox(width: 5),
Text('Private',
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: Colors.white)),
],
),
),
],
dropdownColor: Theme.of(context).primaryColor,
value: 'Public',
onChanged: (value) {
print(value);
}),
),
],
),
],
),
);
}
}
I tried to put the action buttons bar in the floating action button, but it is not full width, and I don't know how to place the images on top of it.
How to make adjust the size of tabba rto 40 in flutter ,how to make 2 tabbar in one screen in flutter please any one colud help with this
Here is the code it might help you.
import 'package:flutter/material.dart';
class StackOverFlowUI extends StatefulWidget {
#override
State<StackOverFlowUI> createState() => _StackOverFlowUIState();
}
class _StackOverFlowUIState extends State<StackOverFlowUI>
with SingleTickerProviderStateMixin {
late TabController _tabController;
#override
void initState() {
_tabController = TabController(length: 3, vsync: this);
super.initState();
}
#override
void dispose() {
super.dispose();
_tabController.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
toolbarHeight: 200,
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
flexibleSpace: Container(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
height: 300,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.topLeft,
colors: [
Color(0xFFd1539d),
Color(0xFF36a4e2),
],
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50),
),
),
child: Column(
children: [
Expanded(
child: Center(
child: RichText(
text: const TextSpan(
children: [
WidgetSpan(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 2.0),
child: Icon(
Icons.bookmark_border,
color: Colors.white,
size: 25,
),
),
),
TextSpan(
text: " Tik Save+",
style: TextStyle(
fontSize: 23,
),
),
],
),
),
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
Icon(
Icons.settings,
color: Colors.white,
),
Icon(
Icons.tiktok,
color: Colors.white,
),
],
)
],
),
),
),
body: DefaultTabController(
length: 3,
child: Scaffold(
bottomNavigationBar: bottomMenu(),
body: TabBarView(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Container(
height: 45,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(
10.0,
),
),
child: TabBar(
controller: _tabController,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(
10.0,
),
color: Colors.grey[800],
),
labelColor: Colors.white,
unselectedLabelColor: Colors.black,
tabs: const [
Tab(
text: 'Videos',
),
Tab(
text: 'Collections',
),
Tab(
text: 'Users',
),
],
),
),
Expanded(
child: TabBarView(
controller: _tabController,
children: const [
Center(
child: Text(
'Videos',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
Center(
child: Text(
'Collections',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
Center(
child: Text(
'Users',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
],
),
),
const Icon(Icons.directions_transit),
const Icon(Icons.directions_bike),
],
),
),
),
);
}
Widget bottomMenu() {
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.topLeft,
colors: [
Color(0xFFd1539d),
Color(0xFF36a4e2),
],
),
),
child: const TabBar(
labelColor: Colors.white,
unselectedLabelColor: Colors.white70,
indicatorSize: TabBarIndicatorSize.tab,
indicatorPadding: EdgeInsets.all(5.0),
indicatorColor: Colors.black,
tabs: [
Tab(
text: "Home",
icon: Icon(Icons.home_outlined),
),
Tab(
text: "Pro",
icon: Icon(Icons.workspace_premium),
),
Tab(
text: "More",
icon: Icon(Icons.more_rounded),
),
],
),
);
}
}
This is what show up on my terminal:
======== Exception caught by rendering library ===================================================== The following assertion was thrown during performLayout(): RenderPhysicalModel object was given an infinite size during layout.
This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that
allows its children to pick their own size. The nearest ancestor
providing an unbounded height constraint is:
_RenderSingleChildViewport#4c3d2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE ... needs compositing ... parentData: (can use size) ... constraints: BoxConstraints(w=1366.0, h=657.0) ... size: MISSING ... offset: Offset(0.0, -0.0) The constraints that applied to the RenderPhysicalModel were: BoxConstraints(0.0<=w<=1366.0,
0.0<=h<=Infinity) The exact size it was given was: Size(1366.0, Infinity)
This is my code:
import 'dart:core';
import 'dart:ui';
import 'package:braintrinig/animation/LongBreak.dart';
import 'package:braintrinig/animation/ShortBreak.dart';
import 'package:braintrinig/animation/StartPomodoro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'dart:async';
import 'package:responsive_sizer/responsive_sizer.dart';
class HomePageTimerUI extends StatefulWidget {
const HomePageTimerUI( {Key? key}) : super(key: key);
#override
State<HomePageTimerUI> createState() => _HomePageTimerUIState();
}
class _HomePageTimerUIState extends State<HomePageTimerUI>
with SingleTickerProviderStateMixin {
final ScrollController _firstController = ScrollController();
late TabController _tabController;
late Timer timer;
late AnimationController controller;
String get countText {
Duration count = controller.duration! * controller.value;
return controller.isDismissed
? '${controller.duration!.inHours.toString().padLeft(2, '0')}:${(controller.duration!.inMinutes % 60).toString().padLeft(2, '0')}:${(controller.duration!.inSeconds % 60).toString().padLeft(2, '0')}'
: '${count.inHours.toString().padLeft(2, '0')}:${(count.inMinutes % 60).toString().padLeft(2, '0')}:${(count.inSeconds % 60).toString().padLeft(2, '0')}';
}
#override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
}
#override
void dispose() {
_tabController.dispose();
super.dispose();
}
void notify() {
if (countText == '00:00:00') {}
}
#override
Widget build(BuildContext context) {
return ResponsiveSizer(builder: (context, orientation, screenType) {
return Device.screenType == ScreenType.mobile
? Container(
width: double.infinity,
child: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
bottom: PreferredSize(
preferredSize: Size.fromHeight(55),
child: Container(
color: Colors.transparent,
child: SafeArea(
child: Column(
children: <Widget>[
TabBar(
controller: _tabController,
indicator: UnderlineTabIndicator(
borderSide: BorderSide(
color: Color(0xff3B3B3B),
width: 4.0),
insets: EdgeInsets.fromLTRB(
12.0, 12.0, 12.0, 11.0)),
indicatorWeight: 15,
indicatorSize: TabBarIndicatorSize.label,
labelColor: Color(0xff3B3B3B),
labelStyle: TextStyle(
fontSize: 12,
letterSpacing: 1.3,
fontWeight: FontWeight.w500),
unselectedLabelColor: Color(0xffD7D7D7),
tabs: [
Tab(
text: "POMODORO",
icon:
Icon(Icons.work_history, size: 40),
),
Tab(
text: "SHORT BREAK",
icon:
Icon(Icons.ramen_dining, size: 40),
),
Tab(
text: "LONG BREAK",
icon: Icon(
Icons.battery_charging_full_rounded,
size: 40),
),
])
],
),
),
),
),
),
body: TabBarView(
controller: _tabController,
children: <Widget>[
Center(
child: StartPomodoro(),
),
Center(
child: ShortBreak(),
),
Center(child: LongBreak()),
],
),
bottomNavigationBar: Container(
height: 110,
color: Color(0xffFAFAFA),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15.0, vertical: 20),
child: GNav(
iconSize: 40,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
backgroundColor: Color(0xffFAFAFA),
color: Color(0xffD7D7D7),
activeColor: Color(0xff3B3B3B),
tabBackgroundColor: Color(0xffF0F0F0),
gap: 8,
onTabChange: (index) {
print(index);
},
padding: EdgeInsets.all(15),
tabs: [
GButton(
icon: Icons.settings,
text: 'Settings',
),
GButton(
icon: Icons.person,
text: "Profile",
),
GButton(
icon: Icons.task,
text: "Tasks",
),
GButton(
icon: Icons.show_chart,
text: "Performance",
),
],
),
),
),
)))
: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SingleChildScrollView(
child: Column(
children: [
SizedBox(
width: constraints.maxWidth,
height: constraints.maxHeight,
child: Scrollbar(
thumbVisibility: true,
controller: _firstController,
child: ListView.builder(
controller: _firstController,
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Container(
height: constraints.maxHeight,
width: double.infinity,
child: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
bottom: PreferredSize(
preferredSize: Size.fromHeight(55),
child: Container(
color: Colors.transparent,
child: SafeArea(
child: Column(
children: <Widget>[
TabBar(
controller:
_tabController,
indicator: UnderlineTabIndicator(
borderSide: BorderSide(
color: Color(
0xff3B3B3B),
width: 4.0),
insets: EdgeInsets
.fromLTRB(
12.0,
12.0,
12.0,
11.0)),
indicatorWeight: 15,
indicatorSize:
TabBarIndicatorSize
.label,
labelColor:
Color(0xff3B3B3B),
labelStyle: TextStyle(
fontSize: 12,
letterSpacing: 1.3,
fontWeight:
FontWeight.w500),
unselectedLabelColor:
Color(0xffD7D7D7),
tabs: [
Tab(
text: "POMODORO",
icon: Icon(
Icons
.work_history,
size: 40),
),
Tab(
text: "SHORT BREAK",
icon: Icon(
Icons
.ramen_dining,
size: 40),
),
Tab(
text: "LONG BREAK",
icon: Icon(
Icons
.battery_charging_full_rounded,
size: 40),
),
])
],
),
),
),
),
),
body: TabBarView(
controller: _tabController,
children: <Widget>[
Center(
child: StartPomodoro(),
),
Center(
child: ShortBreak(),
),
Center(child: LongBreak()),
],
),
bottomNavigationBar: Container(
height: 110,
color: Color(0xffFAFAFA),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15.0, vertical: 20),
child: GNav(
iconSize: 40,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
backgroundColor: Color(0xffFAFAFA),
color: Color(0xffD7D7D7),
activeColor: Color(0xff3B3B3B),
tabBackgroundColor:
Color(0xffF0F0F0),
gap: 8,
onTabChange: (index) {
print(index);
},
padding: EdgeInsets.all(15),
tabs: [
GButton(
icon: Icons.settings,
text: 'Settings',
),
GButton(
icon: Icons.person,
text: "Profile",
),
GButton(
icon: Icons.task,
text: "Tasks",
),
GButton(
icon: Icons.show_chart,
text: "Performance",
),
],
),
),
),
)));
}),
),
),
SizedBox(
child: Scaffold(
backgroundColor: const Color(0xffF6F6F6),
body: TextSelectionTheme(
data: TextSelectionTheme.of(context).copyWith(
selectionColor: Color(0xffD7D7D7),
cursorColor: Color(0xff3B3B3B),
selectionHandleColor: Color(0xffD7D7D7),
),
child: Center(
child: Container(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Center(
child: Text(
"Your email",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
),
const SizedBox(height: 20,),
const Center(
child: SizedBox(
width: 350,
child: TextField(
cursorColor: Color(0xff3B3B3B),
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xffD7D7D7)),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xffD7D7D7)),
),
),
style: TextStyle(
fontSize: 20,
decoration: TextDecoration.none,
decorationStyle: TextDecorationStyle.dotted,
decorationColor: Color(0xffF6F6F6),
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
),
),
const SizedBox(
height: 110,
),
const Center(
child: Text(
"Your password",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),
),
),
const SizedBox(
height: 20,
),
const SizedBox(
height: 110,
),
GestureDetector(
onTap: () {
print("arrow clicked");
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => HomePageTimerUI()));
},
child: Container(
child: Center(
child: Icon(
Icons.arrow_forward,
size: 40,
color: Color(0xff7E7E7E),
),
),
),
)
],
),
),
),
),
),
),
)
],
),
);
}) ;
});
}
}
How to solve this issue?
Thank you in advance for your help, I really appreciate it, and hope you have a great day
Remove width : double.infinity
It will try to create a container of infinite width which will work if the parent widget has bounds
I want to put a TabBer in the middle of the app but getting an error with TabBarView.
I want to put a TabBer in the middle of the app but getting an error with TabBarView.
I want to put a TabBer in the middle of the app but getting an error with TabBarView.
I want to put a TabBer in the middle of the app but getting an error with TabBarView.
This is my code.
import 'package:flutter/material.dart';
import 'package:hospital/CartPage/pages/cartPage.dart';
import 'package:hospital/Drawer/dropdown_menu.dart';
import 'package:hospital/FloatingActionButton/ConsultWithDoctor/consult_with_doctor.dart';
import 'package:hospital/ProductDetailsPage/some_medicines.dart';
import 'package:hospital/ThirdSection/SubCategoryPage/DiseaseDetailsPage/disease_carousel.dart';
import 'package:hospital/constant.dart';
class DiseaseDetailsPage extends StatefulWidget {
#override
_DiseaseDetailsPageState createState() => _DiseaseDetailsPageState();
}
class _DiseaseDetailsPageState extends State<DiseaseDetailsPage> {
#override
Widget build(BuildContext context) {
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
backgroundColor: kGreen,
title: Text(
"Details",
style: TextStyle(fontStyle: FontStyle.italic),
),
actions: [
IconButton(
icon: Icon(Icons.shopping_cart),
// onPressed: () => print("open cart"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Cartpage()),
);
},
),
DropDownMenu(),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: kGreen,
onPressed: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => ConsultWithDoctor())),
tooltip: 'Consult With Doctor',
child: Container(
child: Image(
image: AssetImage(
"assets/icons/cwd.png",
),
color: Colors.white,
width: 40,
height: 40,
),
),
),
body: SingleChildScrollView(
child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
Card(
color: kLightGreen,
elevation: 3.0,
// margin: EdgeInsets.all(10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
// child: Container(
// // color: Colors.green[50],
// height: 330,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 18.0, top: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
"Malaria",
style: TextStyle(
// decoration: TextDecoration.underline,
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
],
),
),
SizedBox(
height: 20,
),
// Carousel(),
DiseaseCarouselPage()
],
),
),
// ),
SizedBox(
height: 20,
),
Card(
elevation: 3.0,
// margin: EdgeInsets.all(10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
color: kLightGreen,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 20,
),
Text(
"Plasmodium spread by mosquitoes",
style: TextStyle(
// decoration: TextDecoration.underline,
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.black),
),
SizedBox(
height: 20,
),
Text(
'''Malaria is a mosquito-borne infectious disease that affects humans and other animals. Malaria causes symptoms that typically include fever, tiredness, vomiting, and headaches. In severe cases, it can cause yellow skin, seizures, coma, or death.\nSymptoms usually begin ten to fifteen days after being bitten by an infected mosquito. If not properly treated, people may have recurrences of the disease months later.[2] In those who have recently survived an infection, reinfection usually causes milder symptoms.[1] This partial resistance disappears over months to years if the person has no continuing exposure to malaria.''',
style: kSubTitleStyle.copyWith(color: Colors.black87),
),
SizedBox(
height: 20,
),
// the tab bar with Four items
SizedBox(
height: 50,
child: AppBar(
backgroundColor: kGreen,
bottom: TabBar(
labelColor: kGreen,
unselectedLabelColor: kWhite,
isScrollable: true,
indicator: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
color: kWhite),
tabs: [
Tab(
text: "All Things",
// icon: Icon(Icons.directions_bike),
),
Tab(
text: 'Disease Types',
// icon: Icon(
// Icons.directions_car,
// ),
),
Tab(
text: 'Home Remedies',
),
Tab(
text: 'Medicine',
),
],
),
),
),
],
),
),
],
),
),
),
);
}
}
Every TabBar must have TabView (what will be shown on clicking of each tabBar).
And Number of TabBar must be equal to the number of children In your TabView
TabBar Cookbook Flutter.dev will help you more