How to use SVG in TabsIcon? - flutter

I am making my first Flutter app and I have a question. I have a bottom navigation bar with icons from flutter. But I want to use SVG icons in the bottom navigation bar. How can I do that?
The code I have so far:
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
int currentPage = 0;
late TabController tabController;
final List<Color> colors = [
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue
];
List<Widget> screens = [
InAppWebViewExampleScreen(),
GoogleScreen(),
GoogleScreen(),
YouTubeScreen(),
];
#override
void initState() {
tabController = TabController(length: 5, vsync: this);
tabController.animation!.addListener(
() {
final value = tabController.animation!.value.round();
if (value != currentPage && mounted) {
changePage(value);
}
},
);
super.initState();
}
void changePage(int newPage) {
setState(() {
currentPage = newPage;
});
}
#override
void dispose() {
tabController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: FrostedBottomBar(
opacity: 0.6,
sigmaX: 5,
sigmaY: 5,
child: TabBar(
indicatorPadding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
controller: tabController,
indicator: const UnderlineTabIndicator(
borderSide: BorderSide(color: Colors.blue, width: 4),
insets: EdgeInsets.fromLTRB(16, 0, 16, 8),
),
tabs: [
TabsIcon(
icons: Icons.home,
color: currentPage == 0 ? colors[0] : Colors.white),
TabsIcon(
icons: Icons.search,
color: currentPage == 1 ? colors[1] : Colors.white),
TabsIcon(
icons: Icons.queue_play_next,
color: currentPage == 2 ? colors[2] : Colors.white),
TabsIcon(
icons: Icons.file_download,
color: currentPage == 3 ? colors[3] : Colors.white),
TabsIcon(
icons: Icons.menu,
color: currentPage == 4 ? colors[4] : Colors.white),
],
),
borderRadius: BorderRadius.circular(500),
duration: const Duration(milliseconds: 800),
hideOnScroll: false,
body: (context, controller) => screens[currentPage]
),
);
}
}
class TabsIcon extends StatelessWidget {
final Color color;
final double height;
final double width;
final IconData icons;
const TabsIcon(
{Key? key,
this.color = Colors.white,
this.height = 60,
this.width = 50,
required this.icons})
: super(key: key);
#override
Widget build(BuildContext context) {
return SizedBox(
height: height,
width: width,
child: Center(
child: Icon(
icons,
color: color,
),
),
);
}
}
I am a beginner in Flutter so if you have a solution, please make it simple. Thanks in advance!

I do not think that is possible with BottomNavigationBar, but you have 2 options either making your icon pack and add it to the application and you can reference to this link or using BottomAppBar instead of BottomNavigationBar which allow having a widget child and you can reference to this link.

It's not possible, you can't use it with iconData, you should remove TabsIcon and try to use another widget.

Related

how to call using rawchip widget

Basically, I have define a list of array but how to call the list on the label. can someone help me
#override
Widget build(BuildContext context) {
return Column(
children: [
Container(
color: AppColor.white,
width: MediaQuery.of(context).size.width,
child: RawChip(
showCheckmark: false,
label: Text(widget.list,
style: TextStyle(
color: isSelected ? Colors.black : const Color.fromARGB(255, 45, 110, 162),
fontFamily: 'Poppins'
),),
backgroundColor: isSelected ? Colors.white : const Color.fromARGB(255, 200, 222, 255),
shape: const StadiumBorder(
side: BorderSide(color: Colors.transparent)),
//selectedColor: Colors.red,
selected: isSelected,
onPressed: (){
setState(() {
isSelected = isSelected ? false : true;
});
},
widget.variableName is used to refer top level widget(StatefulWidget ). To get data within state class, just use local
class MyWidget extends StatefulWidget {
final int widgetData;
const MyWidget({
Key? key,
required this.widgetData,
}) : super(key: key);
#override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
final int stateData = 3;
late int makingLocal;
#override
void initState() {
super.initState();
makingLocal = widget.widgetData;
}
#override
Widget build(BuildContext context) {
...
}
}
in your case it will be just list but.
Container(
child: Column(children: list),
),

Flutter Package Tab Container - Find Active Tab

I have raised this question already but no response yet from the owner of the package https://github.com/sourcemain/tab_container/issues/4 so trying my luck here.
I am in need to identify the current active tab. I need to change color accordingly.
I need to make sure isSelected is sent correctly.
My Parent Widget:
import 'package:flutter/material.dart';
import 'package:tab_container/tab_container.dart';
import 'package:todelete/tab_button.dart';
class TabContainerMain extends StatefulWidget {
const TabContainerMain({Key? key}) : super(key: key);
#override
State<TabContainerMain> createState() => _TabContainerMainState();
}
class _TabContainerMainState extends State<TabContainerMain> {
late final TabContainerController _controller;
int _selectedIndex = 0;
void _setActiveTabIndex() {
_selectedIndex = _controller.index;
}
#override
void initState() {
_controller = TabContainerController(length: 4);
_controller.addListener(_setActiveTabIndex);
super.initState();
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return SizedBox(
height: 300,
child: TabContainer(
// controller: _controller,
isStringTabs: false,
color: Theme.of(context).colorScheme.surface.withOpacity(0.5),
children: const [
Center(child: Text('Tab 1 Contents')),
Center(child: Text('Tab 2 Contents')),
Center(child: Text('Tab 3 Contents')),
Center(child: Text('Tab 4 Contents')),
],
tabs: [
TabButton(
colr: Theme.of(context).colorScheme.inverseSurface,
txt: 'ONGOING',
cnt: 9,
isSelected: _selectedIndex == 0 ? true : false,
),
TabButton(
colr: Colors.red.shade600,
txt: 'TRAPPED',
cnt: 5,
isSelected: _selectedIndex == 1 ? true : false,
),
TabButton(
colr: Theme.of(context).colorScheme.inverseSurface,
txt: 'PLANNED',
cnt: 6,
isSelected: _selectedIndex == 2 ? true : false,
),
TabButton(
colr: Theme.of(context).colorScheme.inverseSurface,
txt: 'COMPLETE',
cnt: 8,
isSelected: _selectedIndex == 3 ? true : false,
),
],
),
);
}
}
My Child Widget:
import 'package:flutter/material.dart';
class TabButton extends StatelessWidget {
final Color colr;
final String txt;
final int cnt;
final bool isSelected;
// final void Function()? onPressed;
const TabButton(
{Key? key,
required this.colr,
required this.txt,
required this.cnt,
required this.isSelected})
: super(key: key);
#override
Widget build(BuildContext context) {
return Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text(
txt + ' ',
style: isSelected
? Theme.of(context).textTheme.bodySmall?.copyWith(
color: const Color(0xFFE90B32), fontWeight: FontWeight.bold)
: Theme.of(context).textTheme.bodySmall,
),
Container(
height: 15,
width: 15,
// padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
color: colr,
borderRadius: const BorderRadius.all(Radius.circular(12))),
child: Center(
child: Text(
cnt.toString(),
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: Theme.of(context).colorScheme.surface),
),
))
],
);
}
}

onTap with Flutter plugin floating_frosted_bottom_bar

I am using the Flutter plugin floating_frosted_bottom_bar, and I want to display a page when the second item is clicked. I don't know how to do this. The code I have so far is this:
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:floating_frosted_bottom_bar/floating_frosted_bottom_bar.dart';
import 'logo_list.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Frosted bottom bar',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Frosted bottom bar'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
late int currentPage;
late TabController tabController;
final List<Color> colors = [
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue
];
#override
void initState() {
currentPage = 0;
tabController = TabController(length: 5, vsync: this);
tabController.animation!.addListener(
() {
final value = tabController.animation!.value.round();
if (value != currentPage && mounted) {
changePage(value);
}
},
);
super.initState();
}
void changePage(int newPage) {
setState(() {
currentPage = newPage;
});
}
#override
void dispose() {
tabController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: FrostedBottomBar(
opacity: 0.6,
sigmaX: 5,
sigmaY: 5,
child: TabBar(
indicatorPadding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
controller: tabController,
indicator: const UnderlineTabIndicator(
borderSide: BorderSide(color: Colors.blue, width: 4),
insets: EdgeInsets.fromLTRB(16, 0, 16, 8),
),
tabs: [
TabsIcon(
icons: Icons.home,
color: currentPage == 0 ? colors[0] : Colors.white),
TabsIcon(
icons: Icons.search,
color: currentPage == 1 ? colors[1] : Colors.white),
TabsIcon(
icons: Icons.queue_play_next,
color: currentPage == 2 ? colors[2] : Colors.white),
TabsIcon(
icons: Icons.file_download,
color: currentPage == 3 ? colors[3] : Colors.white),
TabsIcon(
icons: Icons.menu,
color: currentPage == 4 ? colors[4] : Colors.white),
],
),
borderRadius: BorderRadius.circular(500),
duration: const Duration(milliseconds: 800),
hideOnScroll: false,
body: (context, controller) => TabBarView(
controller: tabController,
dragStartBehavior: DragStartBehavior.down,
physics: const BouncingScrollPhysics(),
children: colors
.map(
(e) => ListView.builder(
controller: controller,
itemBuilder: (context, index) {
return const Card(child: FittedBox(child: FlutterLogo()));
},
),
)
.toList(),
),
),
);
}
}
class TabsIcon extends StatelessWidget {
final Color color;
final double height;
final double width;
final IconData icons;
const TabsIcon(
{Key? key,
this.color = Colors.white,
this.height = 60,
this.width = 50,
required this.icons})
: super(key: key);
#override
Widget build(BuildContext context) {
return SizedBox(
height: height,
width: width,
child: Center(
child: Icon(
icons,
color: color,
),
),
);
}
}
The output I got: https://imgur.com/a/MKkHcEH
I am a beginner in Flutter so if you have a solution, please make it simple. Thanks in advance!
I updated your code, Put your screens in List[Screens] only instead off ffff() , hope it helps.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:floating_frosted_bottom_bar/floating_frosted_bottom_bar.dart';
import 'ffff.dart';
import 'hhkllj.dart';
// import 'logo_list.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Frosted bottom bar',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Frosted bottom bar'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
int currentPage = 0;
late TabController tabController;
final List<Color> colors = [
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue,
Colors.blue
];
List<Widget> Screens = [
fff(),
hhhhh(),
fff(),
hhhhh(),
fff(),
];
#override
void initState() {
tabController = TabController(length: 5, vsync: this);
tabController.animation!.addListener(
() {
final value = tabController.animation!.value.round();
if (value != currentPage && mounted) {
changePage(value);
}
},
);
super.initState();
}
void changePage(int newPage) {
setState(() {
currentPage = newPage;
});
}
#override
void dispose() {
tabController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: FrostedBottomBar(
opacity: 0.6,
sigmaX: 5,
sigmaY: 5,
child: TabBar(
indicatorPadding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
controller: tabController,
indicator: const UnderlineTabIndicator(
borderSide: BorderSide(color: Colors.blue, width: 4),
insets: EdgeInsets.fromLTRB(16, 0, 16, 8),
),
tabs: [
TabsIcon(
icons: Icons.home,
color: currentPage == 0 ? colors[0] : Colors.white),
TabsIcon(
icons: Icons.search,
color: currentPage == 1 ? colors[1] : Colors.white),
TabsIcon(
icons: Icons.queue_play_next,
color: currentPage == 2 ? colors[2] : Colors.white),
TabsIcon(
icons: Icons.file_download,
color: currentPage == 3 ? colors[3] : Colors.white),
TabsIcon(
icons: Icons.menu,
color: currentPage == 4 ? colors[4] : Colors.white),
],
),
borderRadius: BorderRadius.circular(500),
duration: const Duration(milliseconds: 800),
hideOnScroll: false,
body: (context, controller) => Screens[currentPage]
// (context, controller) => TabBarView(
// controller: tabController,
// dragStartBehavior: DragStartBehavior.down,
// physics: const BouncingScrollPhysics(),
// children: colors.map(
// (e) => ListView.builder(
// controller: controller,
// itemBuilder: (context, index) {
// return const Card(child: FittedBox(child: FlutterLogo()));
// },
// ),
// )
// .toList(),
// ),
),
);
}
}
class TabsIcon extends StatelessWidget {
final Color color;
final double height;
final double width;
final IconData icons;
const TabsIcon(
{Key? key,
this.color = Colors.white,
this.height = 60,
this.width = 50,
required this.icons})
: super(key: key);
#override
Widget build(BuildContext context) {
return SizedBox(
height: height,
width: width,
child: Center(
child: Icon(
icons,
color: color,
),
),
);
}
}

Making a Common Button Widget in Flutter

Im making a common Button widget that have three states Active / Disable / Loading.
im managing the status from the place where I use the ButtonWidget.
I'll post what I did so far.
when I try to run the button widget it gets an error. namely
The following assertion was thrown while finalizing the widget tree:
_ButtonWidgetState#ab5a5(ticker active) was disposed with an active Ticker.
_ButtonWidgetState created a Ticker via its SingleTickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. The Ticker must be disposed before calling super.dispose().
I imagine this is due the to animation I already have in my button widget.
can anyone help me to overcome this.?
would be really helpful.
ButtonWidget
import 'package:flutter/material.dart';
import 'dart:async';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
const TextStyle tButtonMedium = TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
);
enum eButtonType {
bText,
bIcon,
bIconText,
}
enum eButtonState {
bActive,
bDisable,
bLoading,
}
void main() {
runApp(MyApp());
}
class CustomColors {
static const Color grey100 = Color(0xFFF0F0F0);
static const Color grey600 = Color(0xFFAFAFAF);
static const Color mWhite = Color(0xFFFFFFFF);
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatefulWidget {
#override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
var _isLoading = false;
eButtonState? btnState;
#override
void initState() {
_makeActive();
super.initState();
}
void _makeActive() {
Future.delayed(
const Duration(seconds: 5),
() => setState(() {
btnState = eButtonState.bActive;
}),
);
}
void _onSubmit() {
setState(() {
btnState = eButtonState.bLoading;
});
Future.delayed(
const Duration(seconds: 10),
() => setState(() {
btnState = eButtonState.bActive;
}));
}
#override
Widget build(BuildContext context) {
return ButtonWidget(
key: UniqueKey(),
onPressed: () {
_onSubmit();
},
btnColor: Colors.white,
borderColor: Colors.blue,
textColor: Colors.blue,
text: "Save",
eButtonState: btnState,
eButtonType: eButtonType.bIconText,
iconData: Icons.save_alt,
);
}
}
////////////////////////////////////////////////////////////////////////
class ButtonWidget extends StatefulWidget {
//
final String? text;
final Color? btnColor;
final Color? borderColor;
final Color? textColor;
final Function? onPressed;
// final bool? isActive;
final eButtonType;
final eButtonState;
final IconData? iconData;
const ButtonWidget({
Key? key,
this.text,
this.btnColor,
this.borderColor,
this.textColor,
this.eButtonType,
this.iconData,
#required this.eButtonState,
#required this.onPressed,
// #required this.isActive,
}) : super(key: key);
#override
_ButtonWidgetState createState() => _ButtonWidgetState();
}
class _ButtonWidgetState extends State<ButtonWidget>
with SingleTickerProviderStateMixin {
late double _scale;
late AnimationController _controller;
#override
void initState() {
_controller = AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 100,
),
upperBound: 0.1,
)..addListener(() {
setState(() {});
});
super.initState();
}
#override
void dispose() {
super.dispose();
_controller.dispose();
}
void buttonHandler() {
_controller.forward();
Timer(const Duration(milliseconds: 50), () {
_controller.reverse();
});
Timer(const Duration(milliseconds: 50), () {
widget.onPressed!();
});
}
#override
Widget build(BuildContext context) {
_scale = 1 - _controller.value;
return Transform.scale(
scale: _scale,
child: ElevatedButton(
style: TextButton.styleFrom(
elevation: widget.eButtonState == eButtonState.bActive ? 2.0 : 0.0,
primary: widget.eButtonState == eButtonState.bActive
? widget.btnColor!
: CustomColors.grey600,
backgroundColor: widget.eButtonState == eButtonState.bActive
? widget.btnColor!
: CustomColors.grey100,
minimumSize: const Size(80.0, 50.0),
maximumSize: const Size(double.infinity, 50.0),
shape: RoundedRectangleBorder(
side: BorderSide(
color: widget.eButtonState == eButtonState.bActive
? widget.borderColor!
: CustomColors.grey100,
width: 2,
),
borderRadius: BorderRadius.circular(16.0),
),
splashFactory: NoSplash.splashFactory,
),
onPressed: () => widget.eButtonState == eButtonState.bActive
? buttonHandler()
: null,
child: widget.eButtonState == eButtonState.bLoading
? const CircularProgressIndicator(
color: CustomColors.grey600,
backgroundColor: Colors.transparent,
)
: (widget.eButtonType == eButtonType.bText
? Text(
widget.text!,
style: tButtonMedium.copyWith(
color: widget.eButtonState == eButtonState.bActive
? widget.textColor!
: CustomColors.grey600,
),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
)
: (widget.eButtonType == eButtonType.bIconText)
? Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
Icon(
widget.iconData,
color: widget.eButtonState == eButtonState.bActive
? widget.textColor
: CustomColors.grey600,
),
Spacer(),
Text(
widget.text!,
style: tButtonMedium.copyWith(
color: widget.eButtonState == eButtonState.bActive
? widget.textColor!
: CustomColors.grey600,
),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
),
Spacer(),
],
)
: Icon(
widget.iconData,
color: widget.eButtonState == eButtonState.bActive
? CustomColors.mWhite
: CustomColors.grey600,
)),
),
);
}
}
I've managed to get to fixed by simply doing
void dispose() {
_controller.dispose();
super.dispose();
}
If anyone wish to have a common button widget. please feel free to use this code. and I appreciate if veterans can guide to improve this widget. cheers

flutter Update list, setstate does not work

video:https://drive.google.com/file/d/1Nh49PxHeCak4YkaCHVec8hQCzgTN7Kr-/view?usp=sharing
The subcomponent clicks on the callback function, and the background color of the subcomponent cannot be changed by changing the value of list
I tried using deep copy and it still didn't work. How can I change the code to switch the background color?
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<bool> tabsActive = [true,false,false,false,false];
void changeTabs(int view) {
print("view:$view");
for(int i = 0;i < tabsActive.length;i++) {
tabsActive[i] = false;
}
setState(() {
tabsActive[view-1] = true;
});
print(tabsActive);
}
#override
Widget build(BuildContext context) {
return Scaffold(
body:Center(
child: Row(
children: <Widget>[
GameTabs("tab1",1,tabsActive[0],changeTabs),
GameTabs("tab2",2,tabsActive[1],changeTabs),
GameTabs("tab3",3,tabsActive[2],changeTabs),
GameTabs("tab4",4,tabsActive[3],changeTabs),
GameTabs("tab5",5,tabsActive[4],changeTabs),
],
),
)
);
}
}
typedef CallIntFun = void Function(int);
class GameTabs extends StatefulWidget {
final String title;
final int view;
final bool active;
CallIntFun changeTabs;
GameTabs(this.title,this.view,this.active,this.changeTabs);
#override
_GameTabsState createState() => _GameTabsState(title,view,active,changeTabs);
}
class _GameTabsState extends State<GameTabs> with SingleTickerProviderStateMixin {
AnimationController _controller;
final String title;
final int view;
final bool active;
Color bgColor;
CallIntFun changeTabs;
_GameTabsState(this.title,this.view,this.active,this.changeTabs);
#override
Widget build(BuildContext context) {
if (active) {
return ActiveGameTabs(title);
}
return Expanded(
child: GestureDetector(
onTap: (){
changeTabs(view);
},
child: Container(
height: 56,
padding: EdgeInsets.fromLTRB(0, 6, 0, 0),
decoration: BoxDecoration(
color: Color.fromRGBO(235, 235, 235, 1),
border: Border.all(
color: Colors.green,
width: 3.0,
style: BorderStyle.none
),
),
child: Text(
title,
textAlign: TextAlign.center,
),
),
)
);
}
}
class ActiveGameTabs extends StatelessWidget {
final String title;
ActiveGameTabs(this.title);
#override
Widget build(BuildContext context) {
return Expanded(
child: Container(
height: 56,
padding: EdgeInsets.fromLTRB(0, 6, 0, 0),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.green,
width: 3.0,
style: BorderStyle.none
),
),
child: Text(
title,
textAlign: TextAlign.center,
),
)
);
}
}
You are passing the values from widget to state when the state is created for the first time. So it won't change when there is a change in any of those property (Because state won't gets created each time). You want to change your GameTab implementation like this:
class GameTabs extends StatefulWidget {
final String title;
final int view;
final bool active;
CallIntFun changeTabs;
GameTabs(this.title,this.view,this.active,this.changeTabs);
#override
_GameTabsState createState() => _GameTabsState();
}
class _GameTabsState extends State<GameTabs> with SingleTickerProviderStateMixin {
AnimationController _controller;
#override
Widget build(BuildContext context) {
if (widget.active) {
return ActiveGameTabs(widget.title);
}
return Expanded(
child: GestureDetector(
onTap: (){
widget.changeTabs(widget.view);
},
child: Container(
height: 56,
padding: EdgeInsets.fromLTRB(0, 6, 0, 0),
decoration: BoxDecoration(
color: Color.fromRGBO(235, 235, 235, 1),
border: Border.all(
color: Colors.green,
width: 3.0,
style: BorderStyle.none
),
),
child: Text(
widget.title,
textAlign: TextAlign.center,
),
),
)
);
}
}