0

#1. I was making a tab menus using tabcontroller, and I wanted to stop its tab scrolling ability, and wanted to select tab using tab menu click.

I was trying with physics: NeverScrollableScrollPhysics(), but failed. As a newbie, I don't understand what is the problem or what I am missing!

Here is A GIF file to illustrate my scenario --> here

#2. In this Scenario, the "Places", means the first tab is maintains a padding, how can I remove it and push it to the left, from where the body started?

Thanks in Advance :)

My Code -->

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'dart:math' as math;
void main() => runApp(StartPage());
class StartPage extends StatelessWidget {
 static const String _title = 'TravelApp';
 @override
 Widget build(BuildContext context) {
 return MaterialApp(
 debugShowCheckedModeBanner: false,
 title: _title,
 home: Scaffold(body: StartPage1()),
 );
 }
}
class StartPage1 extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
 dynamic screenHeight = MediaQuery.of(context).size.height;
 dynamic screenwidth = MediaQuery.of(context).size.width;
 return Scaffold(
 body: Container(
 height: screenHeight,
 width: screenwidth,
 padding: EdgeInsets.symmetric(
 horizontal: screenwidth * 0.03,
 vertical: screenHeight * 0.02,
 ),
 child: Container(
 // Places BAr
 height: screenHeight * 0.20,
 child: MaterialApp(
 debugShowCheckedModeBanner: false,
 home: DefaultTabController(
 length: 3,
 child: Scaffold(
 appBar: PreferredSize(
 preferredSize: Size.fromHeight(screenHeight * 0.076607387),
 child: new Container(
 child: SafeArea(
 child: Column(
 children: <Widget>[
 Expanded(
 child: Container(),
 ),
 Container(
 height: screenHeight * 0.05,
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 screenHeight * 0.02,
 ),
 alignment: Alignment.centerLeft,
 child: TabBar(
 indicator: CircleTabIndicator(
 color: Color(0xFF7675E0),
 radius: 4,
 ),
 isScrollable: true,
 labelColor: Color(0xFF7675E0),
 unselectedLabelColor: Colors.grey,
 physics: NeverScrollableScrollPhysics(),
 tabs: <Widget>[
 Align(
 alignment: Alignment.centerLeft,
 child: Text(
 "Placess",
 style: GoogleFonts.sniglet(),
 ),
 ),
 Tab(
 child: Text(
 "Activities",
 style: GoogleFonts.sniglet(),
 ),
 ),
 Tab(
 child: Text(
 "Hotels",
 style: GoogleFonts.sniglet(),
 ),
 ),
 ],
 ),
 )
 ],
 ),
 ),
 ),
 ),
 body: TabBarView(
 children: <Widget>[
 Container(
 child: Row(
 mainAxisAlignment: MainAxisAlignment.spaceBetween,
 children: <Widget>[
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1002.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Mountain",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1017.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Beach",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1013.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Location",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 screenHeight * 0.012311902,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1002.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "More",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 ],
 ),
 ),
 Container(
 child: Row(
 mainAxisAlignment: MainAxisAlignment.spaceBetween,
 children: <Widget>[
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1004.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Mountain",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1013.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Beach",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1017.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Location",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1004.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "More",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 ],
 ),
 ),
 Container(
 child: Row(
 mainAxisAlignment: MainAxisAlignment.spaceBetween,
 children: <Widget>[
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1002.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Mountain",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1013.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Beach",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1017.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "Location",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 Container(
 width: screenwidth * 0.18,
 child: Column(
 children: <Widget>[
 Container(
 margin: EdgeInsets.fromLTRB(
 0,
 0,
 0,
 9,
 ),
 child: ClipOval(
 child: Material(
 child: InkWell(
 splashColor: Color(0xFF7675E0),
 child: SizedBox(
 width: screenwidth * 0.136253041,
 height: screenHeight * 0.076607387,
 child: Image(
 image:
 AssetImage('assets/1004.png'),
 ),
 ),
 onTap: () {},
 ),
 ),
 ),
 ),
 Text(
 "More",
 style: GoogleFonts.sniglet(
 color: Colors.black45,
 ),
 ),
 ],
 ),
 ),
 ],
 ),
 ),
 ],
 ),
 ),
 ),
 ),
 ),
 ),
 );
 }
}
danronmoon
3,8735 gold badges36 silver badges58 bronze badges
asked Jan 4, 2021 at 8:15
2
  • Why do you have isScrollable: true? Commented Jan 4, 2021 at 9:22
  • @DimaRostopira to align them and in case the tab name excess the limit,then it will hide them, will not break them! Commented Jan 4, 2021 at 10:41

1 Answer 1

3

For the tabbar scrolling issue: you will need to set the NeverScrollableScrollPhysics() in TabBarView's physics property, and not in the TabBar's physics property.

answered Jun 23, 2021 at 13:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.