I am using CarouselSlider to slide my containers but issue is its showing lot of padding on the left side.
My code
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
double statusbar = MediaQuery.of(context).padding.top;
final DateTime now = DateTime.now();
final DateFormat formatter = DateFormat('E, MMM d, y');
final String formatted = formatter.format(now);
print(formatted); // something like 2013-04-20
return Scaffold(
backgroundColor: Color(0xFF612c58),
body: Column(
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(40), bottomRight: Radius.circular(40)),
child: Container(
color: Colors.white,
height: height * 0.52,
child: Column(
children: <Widget>[
SizedBox(
height: statusbar * 2,
),
Container(
padding: EdgeInsets.only(left: 30, right: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Popular',
style: TextStyle(fontSize: 23, fontWeight: FontWeight.bold),
),
Text("$formatted")
],
),
),
CarouselSlider(
options: CarouselOptions(height: height * 0.39,
enableInfiniteScroll: false,
),
items: [0, 1, 2, 3, 4].map((i) {
return Builder(
builder: (BuildContext context) {
return _popular(i);
},
);
}).toList(),
),
Container(
height: height * 0.006,
width: width * 0.1,
color: Colors.grey,
),
],
),
),
),
SizedBox(height: height * 0.02,),
Container(
padding: EdgeInsets.only(left: 20),
width: double.infinity,child: Text('Recent Stories', style: TextStyle(color: Colors.white, fontSize: 21, fontWeight: FontWeight.bold),))
],
),
);
}
Widget _popular(int index) {
double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
double statusbar = MediaQuery.of(context).padding.top;
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: height * 0.02,),
ClipRRect(
borderRadius: BorderRadius.circular(70.0),
child: Container(
height: height * 0.25,
width: width * 0.7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/1.png',
),
),
),
),
),
SizedBox(height: height * 0.01,),
Container(
padding: EdgeInsets.only(left: 15),
width: double.infinity,
child: Text(
'Amazing lesson Story',
style: TextStyle(fontWeight: FontWeight.bold),
)),
SizedBox(height: height * 0.01,),
Container(
padding: EdgeInsets.only(left: 15),
width: double.infinity,
child: Text(
'Post By Marco - 10 min',
)),
],
));
}
}
As you can see its showing gap on left side i need to remove this and need to set padding between the slides. I also check the documentation but there is no option showing for padding or i maybe its have any option but i am not able to find it. Can any one please tell how can i just remove the padding and add gap between sldies Thanks :)
CarouselOptions has padEnds attribute which you can set to false to remove the padding from both ends of the list.
Source: a possible duplicate of this question
One option could be adding alignment to the container that wraps your child in the itemBuilder :
#override
Widget build(BuildContext context) {
return CarouselSlider.builder(
carouselController: carouselController,
options: CarouselOptions(
disableCenter: false,
viewportFraction: 0.8,
enlargeCenterPage: false,
height: getProportionateScreenHeight(defaultCarouselHeight),
enableInfiniteScroll: false,
initialPage: 0,
onPageChanged: onPageChanged,
enlargeStrategy: CenterPageEnlargeStrategy.height,
),
itemCount: model.topNewsList.length,
itemBuilder: (context, index, realindex) => Container(
alignment: const Alignment(-1.5, -1.0),
child: CarouselCell(
news: model.topNewsList[index],
onNewsPress: () => Get.to(
() => DetailScreen(),
arguments: model.topNewsList[index],
),
),
),
);
}
as you see, I added the alignment to -1,5 for the left - right, and -1 for the top - bottom, according to this explanation : https://youtu.be/g2E7yl3MwMk
I know this is not the cleanest way to do that, so if anybody else finds another solution, that would be helpful for all :)
try adding these options to CarouselOptions
aspectRatio: 2.0,
disableCenter: true,
viewportFraction: 1,
enlargeCenterPage: false,
If you want to show a small part of a next image on the right try reducing the viewportFraction to 0.95.
You can see all the options that can be passed to the CarouselOptions by ctrl+click on CarouselOptions in VSCODE
Related
I'm trying to make a music app and I'm in trouble with modifying positions of 'Playlist of the week' text and the Listview of the images right now. I want to make those two properties more upwards but I have no idea what to do.
This is my home.dart file
import 'package:flutter/material.dart';
import 'package:secondlife_mobile/PageViewHolder.dart';
import 'package:provider/provider.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final PageStorageBucket bucket = PageStorageBucket();
late PageViewHolder holder;
late PageController _controller;
double fraction =
0.57; // By using this fraction, we're telling the PageView to show the 50% of the previous and the next page area along with the main page
#override
void initState() {
super.initState();
holder = PageViewHolder(value: 2.0);
_controller = PageController(initialPage: 2, viewportFraction: fraction);
_controller.addListener(() {
holder.setValue(_controller.page);
});
}
int index = 1;
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: const Color.fromARGB(255, 223, 234, 244),
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
title: const Text('AppBar'),
),
body: SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 30,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 35),
child: Text(
'Playlist for you',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
),
),
),
const SizedBox(height: 35),
Container(
child: Center(
child: AspectRatio(
aspectRatio: 1,
child: ChangeNotifierProvider<PageViewHolder>.value(
value: holder,
child: PageView.builder(
controller: _controller,
itemCount: 4,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
return MyPage(
number: index.toDouble(),
fraction: fraction,
);
}),
),
),
),
),
////Your Playlist of the week text
const Padding(
padding: EdgeInsets.symmetric(horizontal: 35),
child: Text(
'Playlist of the week',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 35),
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: 150,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
InkWell(
onTap: () {},
child: Ink(
child: SizedBox(
height: 160.0,
width: 200.0,
child: Image.asset(
'assets/images/album1.jpg',
height: 160.0,
width: 200.0,
),
),
),
),
const SizedBox(
width: 30,
),
InkWell(
onTap: () {},
child: Ink(
child: SizedBox(
height: 160.0,
width: 200.0,
child: Image.asset(
'assets/images/album2.jpg',
height: 160.0,
width: 200.0,
),
),
),
),
const SizedBox(
width: 30,
),
InkWell(
onTap: () {},
child: Ink(
child: SizedBox(
height: 160.0,
width: 200.0,
child: Image.asset(
'assets/images/album3.jpg',
height: 160.0,
width: 200.0,
),
),
),
),
const SizedBox(
width: 30,
),
InkWell(
onTap: () {},
child: Ink(
child: SizedBox(
height: 160.0,
width: 200.0,
child: Image.asset(
'assets/images/album4.jpg',
height: 160.0,
width: 200.0,
),
),
),
),
const SizedBox(
width: 30,
),
InkWell(
onTap: () {},
child: Ink(
child: SizedBox(
height: 160.0,
width: 200.0,
child: Image.asset(
'assets/images/album5.jpg',
height: 160.0,
width: 200.0,
),
),
),
),
],
),
),
],
),
),
),
],
),
),
),
),
);
}
}
class MyPage extends StatelessWidget {
final number;
final double? fraction;
const MyPage({super.key, this.number, this.fraction});
#override
Widget build(BuildContext context) {
double? value = Provider.of<PageViewHolder>(context).value;
double diff = (number - value);
// diff is negative = left page
// diff is 0 = current page
// diff is positive = next page
//Matrix for Elements
final Matrix4 pvMatrix = Matrix4.identity()
..setEntry(3, 2, 1 / 0.9) //Increasing Scale by 90%
..setEntry(1, 1, fraction!) //Changing Scale Along Y Axis
..setEntry(3, 0, 0.004 * -diff); //Changing Perspective Along X Axis
final Matrix4 shadowMatrix = Matrix4.identity()
..setEntry(3, 3, 1 / 1.6) //Increasing Scale by 60%
..setEntry(3, 1, -0.004) //Changing Scale Along Y Axis
..setEntry(3, 0, 0.002 * diff) //Changing Perspective along X Axis
..rotateX(1.309); //Rotating Shadow along X Axis
return Stack(
fit: StackFit.expand,
alignment: FractionalOffset.center,
children: [
Transform.translate(
offset: const Offset(0.0, -47.5),
child: Transform(
transform: pvMatrix,
alignment: FractionalOffset.center,
child: Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
blurRadius: 11.0,
spreadRadius: 4.0,
offset: const Offset(
13.0, 35.0), // shadow direction: bottom right
)
]),
child: Image.asset(
"assets/images/image_${number.toInt() + 1}.jpg",
fit: BoxFit.fill),
),
),
),
],
);
}
}
And this is the image that I'm expecting right now.
Yeah, I solved it with wrapping the Padding of both text and the ListView with Transform.translate and did some tinkering with the offset.
Thank God I solved this! :)
Try to place a column inside the singlechildscrollview and define mainaxisalignment as min
Set height property of Container widget wrapping PageView.
i created a carousel containing three different images. the problem is these images are not taking the full length of my current screen. i have tried setting the width in the image and even setting the aspect ratio and viewport in carousel options but the outcome is still the same. help would be very much appreciated. here is the code.
final List<Widget> _images = [
Stack(
children: [
Image.asset('assets/images/image 10.png'),
Padding(
padding: const EdgeInsets.only(left: 55.0, top: 230),
child: Text(
'Luxury \n Fashion \n &Accessories'.toUpperCase(),
style: TextStyle(
fontFamily: 'Bodoni',
fontSize: 40,
fontWeight: FontWeight.w500,
color: Colors.grey.shade700
),
),
),
Padding(
padding: const EdgeInsets.only(top: 400.0),
child: Center(
child:SvgPicture.asset('assets/iconImages/Button.svg'),
),
),
],
),
Image.asset('assets/images/leeloo.jpeg', width: double.infinity,),
Image.asset('assets/images/ayaka.jpeg', width: double.infinity,),
];
#override
Widget build(BuildContext context) {
return DefaultTabController(
length: 5,
child: Column(
children: [
Stack(
children: [
CarouselSlider.builder(
options: CarouselOptions(
viewportFraction: 1,
aspectRatio: 16/9,
height: MediaQuery.of(context).size.height*0.78,
autoPlay: false,
initialPage: 0,
enableInfiniteScroll: false,
enlargeCenterPage: true,
onPageChanged: (index, reason){
setState(() {
_activeIndex = index;
});
}
),
itemCount: _images.length,
itemBuilder: (BuildContext context, int index, int realIndex) {
return GestureDetector(
onTap: (){
Navigator.of(context).pushNamedAndRemoveUntil(BlackScreen.routeName, (route) => false);
},
child: Align(
alignment: Alignment.bottomCenter,
child:Container(
child: _images[index]
),
),
);
},
),
Set fit to your image like this:
Image.asset('assets/images/leeloo.jpeg', width: double.infinity,fit: BoxFit.cover),
Please try this
FittedBox(
child: Image.asset('foo.png'),
fit: BoxFit.fill,
)
how to add these images in carousal in flutter
Use this carousel_slider 4.0.0 package from pubdev.
Installation
Add carousel_slider: ^4.0.0 to your pubspec.yaml dependencies. And import it:
import 'package:carousel_slider/carousel_slider.dart';
How to use
Simply create a CarouselSlider widget, and pass the required params:
CarouselSlider(
options: CarouselOptions(height: 400.0),
items: [1,2,3,4,5].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Colors.amber
),
child: Text('text $i', style: TextStyle(fontSize: 16.0),)
);
},
);
}).toList(),
)
https://pub.dev/packages/smooth_page_indicator you can use this for dot animation along with https://pub.dev/packages/carousel_slider here is a little example please adjust size accordingly
class Carosel extends StatelessWidget {
List<listScreen> introduction = [
listScreen(image: 'assets/Reading_Plans.png'),
listScreen(image: 'assets/Reading_Plans.png'),
listScreen(image: 'assets/Reading_Plans.png'),
listScreen(image: 'assets/Reading_Plans.png'),
];
set index(value) => _index.value = value;
get index => _index.value;
final _index = 0.obs;
final CarouselController _controller = CarouselController();
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: MediaQuery.of(context).size.width / 1.5,
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height / 2,
child: CarouselSlider(
carouselController: _controller,
options: CarouselOptions(
enableInfiniteScroll: false,
viewportFraction: 1,
height: MediaQuery.of(context).size.height / 3,
aspectRatio: 1.0,
onPageChanged: (ind, reason) {
index = ind;
}),
items: introduction
.map((listScreen item) => Column(
children: [
SizedBox(
height: kToolbarHeight / 2,
),
Container(
child: Image(
image: AssetImage(item.image),
),
),
SizedBox(
height: 20,
),
// Spacer(),
],
))
.toList(),
),
),
Spacer(),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 35.0,
vertical: 15,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(() {
return index != 3
? Container(
width: 90,
child: AnimatedSmoothIndicator(
activeIndex: index,
count: 4,
effect: ExpandingDotsEffect(
dotHeight: 13,
dotWidth: 13,
activeDotColor: Color(0xff5C5C78),
),
),
: Container();
}),
],
),
),
Spacer(),
],
),
),
),
);
}
}
The other answers are correct and fully functional. You can use
carousel_slider: ^4.0.0
or simply follow the following link to get a complete understanding of code.
https://www.youtube.com/watch?v=JEMx2ax0734&t=279s
I am using ListView.builder. In this, I need to set heights for the individual children. As of now, I'm achieving this using a SizedBox, but this doesn't give me the effect I want.
This is important because some of the children are column widgets like this:
return Column(
children: List.generate( //using List.generate for building the UI
data.length, //I don't know this length beforehand
(int i) => Padding(
padding: EdgeInsets.only(
left: 30.0, right: 30.0, bottom: height * 0.05),
child: EducationMobileCard(
//contents here
),
),
),
);
I want to wrap all widgets like this in a parent ListView.builder. Such that, when the user scrolls, each widget takes up the space that is required to fit its contents. Wrapping the widgets in SizedBox doesn't handle overflows. I've tried ConstrainedBox too. But it doesn't let the other parts of the UI access the vacant screen in case a widget hasn't taken up the entire maxWidth. It just simply keeps the space vacant.
This is the ListView.builder widget I'm currently using:
ListView.builder(
itemCount: 7,
itemBuilder: (context, index) {
return SizedBox(height: height, child: widgetList[index]); //height is the screen height here
}
),
I simply want something that specifies the minimum space to occupy but lets the widget handle the maximum space to take within the ListView.builder.
Edit: This is the EducationMobileCard widget:
import 'package:flutter/material.dart';
import '../custom/text_style.dart';
import '../theme/config.dart';
class EducationMobileCard extends StatefulWidget {
const EducationMobileCard(
{Key? key,
//the required parameters
)
: super(key: key);
final double height, width;
final String insttution, location, years, grades, desc, image;
#override
_EducationMobileCardState createState() => _EducationMobileCardState();
}
class _EducationMobileCardState extends State<EducationMobileCard> {
bool isHover = false;
#override
Widget build(BuildContext context) {
return AnimatedContainer(
decoration: BoxDecoration(
boxShadow: [
//contents
],
),
duration: const Duration(milliseconds: 200),
padding: EdgeInsets.only(
top: isHover ? widget.height * 0.005 : widget.height * 0.01,
bottom: !isHover ? widget.height * 0.005 : widget.height * 0.01),
child: InkWell(
onTap: () {},
onHover: (bool value) {
setState(() {
isHover = value;
});
},
child: Container(
alignment: Alignment.topCenter,
padding: EdgeInsets.only(
top: widget.height * 0.04,
left: widget.width * 0.015,
right: widget.width * 0.015,
bottom: widget.height * 0.04),
width: widget.width,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: isHover ? Colors.black12 : Colors.black45,
blurRadius: 10.0,
offset: const Offset(8, 12),
)
],
color: currentTheme.currentTheme == ThemeMode.dark
? Theme.of(context).cardColor
: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(
5.0,
),
),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.asset(
'assets/education/${widget.image}',
scale: 1.2,
)),
),
FittedBox(
fit: BoxFit.cover,
child: text(widget.insttution, 25, Colors.white)),
Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: FittedBox(
fit: BoxFit.cover,
child: text(widget.location, 10, Colors.white)),
),
FittedBox(
fit: BoxFit.cover,
child: Padding(
padding: const EdgeInsets.only(bottom: 11.0),
child: text(
widget.years != ''
? 'Years of study: ${widget.years}'
: '',
12,
Colors.white),
)),
FittedBox(
fit: BoxFit.cover,
child: text(widget.desc, 15, Colors.white)),
FittedBox(
fit: BoxFit.cover,
child: text(
widget.grades != ''
? 'Grades Achieved: ${widget.grades}'
: '',
12,
Colors.white)),
],
),
),
),
),
);
}
}
You can use ConstrainedBox to set the maxmium and minimum hight.
Refer the example below
ConstrainedBox(
constraints: new BoxConstraints(
minHeight: 35.0,
maxHeight: 160.0,
),
child: new ListView(
shrinkWrap: true,
children: <Widget>[
new ListItem(),
new ListItem(),
],
),
)
You can then use the shrinkWrap proper to wrap the unused space like this:-
shrinkWrap: true,
Thank you
I am trying to achieve something like this in the video https://youtu.be/tpfP7wlHCxw , when the slider image will change the below text will also change like fat in the video example, and also one container box on the front image only
I tried the carousel_slider and use the stack for box frame that is in the video but frame size and image sizes not adjustable
and the important thing is how can I change the below text on change image and slider should not rotate it will stop if the last image comes
here is my code
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:trainer_app/color.dart';
class FatGet extends StatefulWidget {
#override
_GetAgeState createState() => _GetAgeState();
}
final List<String> imgList = [
'https://images.unsplash.com/photo-1520342868574-5fa3804e551c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ff92caffcdd63681a35134a6770ed3b&auto=format&fit=crop&w=1951&q=80',
'https://images.unsplash.com/photo-1522205408450-add114ad53fe?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=368f45b0888aeb0b7b08e3a1084d3ede&auto=format&fit=crop&w=1950&q=80',
'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=94a1e718d89ca60a6337a6008341ca50&auto=format&fit=crop&w=1950&q=80',
'https://images.unsplash.com/photo-1523205771623-e0faa4d2813d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=89719a0d55dd05e2deae4120227e6efc&auto=format&fit=crop&w=1953&q=80',
'https://images.unsplash.com/photo-1508704019882-f9cf40e475b4?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=8c6e5e3aba713b17aa1fe71ab4f0ae5b&auto=format&fit=crop&w=1352&q=80',
'https://images.unsplash.com/photo-1519985176271-adb1088fa94c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a0c8d632e977f94e5d312d9893258f59&auto=format&fit=crop&w=1355&q=80'
];
class _GetAgeState extends State<FatGet> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: background,
body: SafeArea(
child: Column(
children: [
SizedBox(height: 50,),
Center(
child: Stack(
children: [
Container(
height: 5,
width: MediaQuery.of(context).size.height/2,
color: backcolor,
),
Container(
height: 5,
width: MediaQuery.of(context).size.height/2.5,
color: textcolor,
),
],
),
),
SizedBox(height: 50,),
Text('Estimated your current',style: TextStyle(fontFamily: font1,fontSize: 30,fontWeight: FontWeight.w300),),
Text('body Fat Percentage?',style: TextStyle(fontFamily: font1,fontSize: 30,fontWeight: FontWeight.w300),),
SizedBox(height: 100,),
// Image.asset('assets/fat2.png'),
Stack(
children: [
Center(
child: Container(
margin: EdgeInsets.only(bottom: 15),
width: 350,
height: 260,
decoration: BoxDecoration(
border: Border.all(color: textcolor,width: 3, )
),
),
),
Column(
children: [
SizedBox(height: 7,),
CarouselSlider(
options: CarouselOptions(),
items: imgList.map((item) => Container(
child: Padding(
padding: const EdgeInsets.only(left: 5,right: 5),
child: Image.network(item, fit: BoxFit.cover,height: 20,),
),
)).toList(),
),
],
),
],
),
Spacer(),
Container(
margin: EdgeInsets.only(bottom: 30),
width: MediaQuery.of(context).size.width/1.2,
height: 50,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: RaisedButton(
child: Text('Next',style: TextStyle(color: Colors.white,fontFamily: font1,fontWeight: FontWeight.w400,fontSize: 20),),
onPressed: (){
Navigator.pushNamed(context, "Exercise");
},
color: textcolor,
),
),
)
],
),
),
);
}
}
With onPageChange, you can take the value of a variable and return it from a function you send. I think it will work.
Define each text as companent.
Check the index of images with a variable
Write the function that returns value according to the parameter sent.
Call the function and give the control variable
for slider should not rotate.. see comment 1 in the code
for change the below text on change.. see comment 2
CarouselSlider(
items: items,
options: CarouselOptions(
height: 400,
aspectRatio: 16/9,
viewportFraction: 0.8,
initialPage: 0,
enableInfiniteScroll: false, // (1) Set to false
reverse: false,
autoPlay: true,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
enlargeCenterPage: true,
onPageChanged: changeActiveImageText(), // (2) Set up your function here
scrollDirection: Axis.horizontal,
)
)
Function will look something like this
changeActiveImageText(){
// your method of changing the text
setState((){})
}