How to apply linear gradient in the flutter charts?
I have tried with colors class but i am able to apply only a solid color and unable to find a way for using gradient in the graph bars.
chart.Series<Person,String>(
id:"Person3",
colorFn:(_,__)=>chart.MaterialPalette.red.shadeDefault,
domainFn: (Person dataPoint, _)=>dataPoint.name,
measureFn: (Person dataPoint, _)=>dataPoint.no,
data:data2,
)
Provide me some way to apply linear gradient
Apparently there is no such functionality yet. I managed to get it working with the following code:
Widget _buildChart() {
return Container(
height: 300,
child: ShaderMask(
child: charts.BarChart(
_createRandomData(),
animate: true,
primaryMeasureAxis: new charts.NumericAxisSpec(
renderSpec: new charts.NoneRenderSpec(), showAxisLine: false),
domainAxis: new charts.OrdinalAxisSpec(
showAxisLine: false, renderSpec: new charts.NoneRenderSpec()),
layoutConfig: new charts.LayoutConfig(
leftMarginSpec: new charts.MarginSpec.fixedPixel(0),
topMarginSpec: new charts.MarginSpec.fixedPixel(0),
rightMarginSpec: new charts.MarginSpec.fixedPixel(0),
bottomMarginSpec: new charts.MarginSpec.fixedPixel(0)),
defaultRenderer: new charts.BarRendererConfig(
cornerStrategy: const charts.ConstCornerStrategy(30)),
),
shaderCallback: (Rect bounds) {
return LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [Color(0xFF51DE93), Color(0xFFFFB540), Color(0xFFFA4169)],
stops: [
0.0,
0.5,
1.0,
],
).createShader(bounds);
},
blendMode: BlendMode.srcATop,
)
);
}
Result:
An Example of AreaSeries chart
#override
Widget build(BuildContext context) {
final List<Color> color = <Color>[];
color.add(Colors.blue[50]);
color.add(Colors.blue[100]);
color.add(Colors.blue);
final List<double> stops = <double>[];
stops.add(0.0);
stops.add(0.5);
stops.add(1.0);
final LinearGradient gradientColors =
LinearGradient(colors: color, stops: stops);
return Container(
width: double.infinity,
height: 250,
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <AreaSeries<SalesData, String>>[
AreaSeries<SalesData, String>(
dataSource: <SalesData>[
SalesData('Jan', 85),
SalesData('Feb', 58),
SalesData('Mar', 64),
SalesData('Apr', 62),
SalesData('May', 78),
SalesData('Jun', 92),
SalesData('Jul', 90),
],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
gradient: gradientColors,
),
],
),
);
}
Use the property BoxDecoration of Container can implement it , like this :
#override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 370,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors(0XFFA573FF),
blurRadius: 10,
offset: Offset(2, 3)),
],
borderRadius: BorderRadius.all(Radius.circular(18)),
gradient: LinearGradient(colors: [
color: Colors(0XFFA573FF),
color: Colors(0XFF645AFF),
], stops: [
0.35,
1
], begin: Alignment.topLeft, end: Alignment.bottomRight)),
child:
SizedBox(
height: 280,
width: double.infinity,
child: StackedAreaCustomColorLineChart(
StackedAreaCustomColorLineChart._createSampleData())
// replace child with your chart here
),
);
}
Related
I want to make a chart with color like below:
But, this is my first time to make a chart, I only know to give a single color, like mine below:
Here I attach the code of my chart:
Padding(
padding: const EdgeInsets.only(
bottom: 28,
left: 40,
right: 40,
),
child: SizedBox(
width: cardWidth,
child: SfCartesianChart(
margin: EdgeInsets.zero,
legend: Legend(
position: LegendPosition.top,
isVisible: true,
textStyle: body1(),
),
tooltipBehavior: TooltipBehavior(enable: true),
primaryXAxis: CategoryAxis(
labelStyle: body2(),
),
primaryYAxis: NumericAxis(labelStyle: body2()),
series: <ChartSeries<dynamic, dynamic>>[
SplineAreaSeries<ChartData, String>(
color: ColorName.brandPrimaryBlue,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.data,
yValueMapper: (ChartData data, _) =>
data.totalTruck,
name: 'Truck',
markerSettings: const MarkerSettings(
isVisible: false,
color: ColorName.brandPrimaryBlue,
),
),
],
),
),
),
Any advice would be appreciated.
you can use gradient property of SplineAreaSeries like this:
SplineAreaSeries<SalesData, String>(
gradient: const LinearGradient(
colors: <Color>[
Color.fromARGB(80, 9, 59, 167),
Color(0xFF012168),
],
stops: <double>[0.2, 0.7],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
dataSource: <SalesData>[
SalesData('Jan', 35),
SalesData('Feb', 28),
SalesData('Mar', 34),
SalesData('Apr', 32),
SalesData('May', 40)
],
xValueMapper: (SalesData sales, _) =>
sales.year,
yValueMapper: (SalesData sales, _) =>
sales.sales,
// Enable data label
dataLabelSettings:
DataLabelSettings(isVisible: true),
markerSettings: const MarkerSettings(
isVisible: false,
color: Colors.red,
),
)
which will give you results like this:
which you can customize by chagning the colors values etc according to your choice.
I have some draggable pictures and 3 different drag targets. With each picture I have passed a position argument which stores whether the picture should be in first dragtarget or second or third. How can i access that position whenever a picture is droped on the target what is the position. is that the correct target. Thankyou.
// ignore_for_file: prefer_const_constructors, file_names, non_constant_identifier_names
import 'dart:async';
import 'package:dyslexia/pages/level2/round3/Q2spell.dart';
import 'package:dyslexia/utilities/nextButton.dart';
import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart';
import '../../../utilities/QuestionWidget.dart';
class Q1MTP extends StatefulWidget {
const Q1MTP({Key? key}) : super(key: key);
#override
State<Q1MTP> createState() => _Q1MTPState();
}
class _Q1MTPState extends State<Q1MTP> {
String question = "Match the Picture with correct sentence?";
var changeButton = false;
var score = 0;
final FlutterTts flutterTts = FlutterTts();
// ignore: recursive_getters
speak(word) async {
await flutterTts.setLanguage("en-US");
await flutterTts.setPitch(1);
await flutterTts.setVolume(10.0);
await flutterTts.speak(word);
}
var letter = "A";
bool isPlayingMsg = false;
bool draged1 = false;
bool draged2 = false;
bool draged3 = false;
bool color = false;
bool correct = false;
var sentence1 = "The cat is on the mat";
var sentence2 = "The car is driving on the road";
var sentence3 = "The cat is running after the mouse";
double timer = 20.0;
bool canceltimer = false;
String showtimer = "30";
int pos1 = 1;
int pos2 = 2;
int pos3 = 3;
void starttimer() async {
const onesec = Duration(seconds: 1);
Timer.periodic(onesec, (Timer t) {
if (mounted) {
setState(() {
if (timer < 1) {
t.cancel();
//Navigator.of(context).pushReplacement(
// MaterialPageRoute(builder: (context) => Q11sound()));
} else if (canceltimer == true) {
t.cancel();
} else {
timer = timer - 1;
}
showtimer = timer.toString();
});
}
});
}
#override
void initState() {
starttimer();
super.initState();
}
// double line = ((timer.toDouble() - 1.0) / (20.0 - 1.0));
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
backgroundColor: Colors.cyan,
title: Text("AD&DY"),
),
body: Padding(
padding: const EdgeInsets.all(14.0),
child: SingleChildScrollView(
child: Column(children: [
/*
LinearPercentIndicator(
width: MediaQuery.of(context).size.width - 60,
animation: true,
lineHeight: 20.0,
animationDuration: 2000,
percent: ((timer.toDouble() - 1.0) / (20.0 - 1.0)),
center: Text(timer.toString()),
trailing: Icon(Icons.timer),
linearStrokeCap: LinearStrokeCap.roundAll,
progressColor: Colors.greenAccent,
),
*/
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
QuestionWidget(question: question),
SizedBox(height: MediaQuery.of(context).size.height * 0.05),
Divider(
thickness: 1.0,
),
SizedBox(height: MediaQuery.of(context).size.height * 0.05),
Column(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: const [
Colors.cyan,
Colors.white,
],
)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
draggablePic("assets/images/$sentence3.png", pos3),
draggablePic("assets/images/$sentence1.jpg", pos1),
draggablePic("assets/images/$sentence2.jpg", pos2),
],
),
),
SizedBox(height: MediaQuery.of(context).size.height * 0.05),
Wrap(
spacing: 10,
runSpacing: 15,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
option(sentence1),
DragTarget<Image>(
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Material(
borderRadius: BorderRadius.circular(80),
child: Container(
height: 50,
width: 50,
color: Color.fromARGB(255, 255, 255, 255),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: const [
Colors.white,
Colors.cyan,
],
)),
)),
);
},
onAccept: (dragW) {
setState(() {
draged1 = true;
});
},
),
]),
Divider(
thickness: 3,
indent: 50,
endIndent: 50,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
option(sentence2),
DragTarget<Image>(
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Material(
borderRadius: BorderRadius.circular(80),
child: Container(
height: 50,
width: 50,
color: Color.fromARGB(255, 255, 255, 255),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: const [
Colors.white,
Colors.cyan,
],
)),
)),
);
},
onAccept: (dragW) {
setState(() {});
},
),
]),
Divider(
thickness: 3,
indent: 50,
endIndent: 50,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
option(sentence3),
DragTarget<Image>(
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Material(
borderRadius: BorderRadius.circular(80),
child: Container(
height: 50,
width: 50,
color: Color.fromARGB(255, 255, 255, 255),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: const [
Colors.white,
Colors.cyan,
],
)),
)),
);
},
onAccept: (dragW) {
setState(() {});
},
),
]),
Divider(
thickness: 3,
indent: 50,
endIndent: 50,
),
],
),
],
),
SizedBox(height: MediaQuery.of(context).size.height * 0.1),
nextButton(changeButton: changeButton, Location: Q2spell()),
]),
),
),
);
}
Widget option(sentence) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Material(
elevation: 3,
child: Container(
color: Color.fromARGB(255, 153, 209, 216),
height: MediaQuery.of(context).size.height * 0.07,
width: MediaQuery.of(context).size.width * 0.6,
child: Center(child: Text(sentence)),
),
)
],
);
}
Widget draggablePic(pic, position) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Draggable<Image>(
// Data is the value this Draggable stores.
//data: position,
feedback: Image(
image: AssetImage(pic),
height: 90,
width: 90,
),
childWhenDragging: Material(
borderRadius: BorderRadius.circular(10),
child: Container(
height: 50.0,
width: 70.0,
color: Color.fromARGB(255, 255, 255, 255),
),
),
// onDragEnd: changecolor(),
child: Image(
image: AssetImage(pic),
height: 80,
width: 80,
))
],
);
}
}
i'm new in Flutter. i want to make full screen gradient background color use IntroductionScreen widget. however, when i use gradient color in box decoration there is white box space in the bottom. I don't want that to happen. This is my code
return IntroductionScreen(
pages: [
PageViewModel(
title: "Hallo1",
body:
"Instead of having to buy an entire share, invest any amount you want.",
image: buildImage('assets/onboard1bg.png'),
decoration: buildDecoration(),
),
PageViewModel(
title: "Hallo2",
body:
"Instead of having to buy an entire share, invest any amount you want.",
image: buildImage('assets/onboard2bg.png'),
decoration: buildDecoration(),
),
],
showNextButton: false,
showDoneButton: false,
showSkipButton: false,
dotsDecorator: getDotDecoration(),
globalFooter: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: [
ElevatedButton(
child: Text(
'Login',
style: TextStyle(color: Colors.white),
),
onPressed: () {
CupertinoModalBottom(context, "Login", SignIn(), true);
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(50),
primary: Colors.orange,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
],
),
),
);
}
DotsDecorator getDotDecoration() => DotsDecorator(
color: Colors.grey,
size: Size(15, 8),
activeColor: Colors.white,
activeSize: Size(25, 8),
activeShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
);
Widget buildImage(String path) => Center(child: Image.asset(path));
PageDecoration buildDecoration() => PageDecoration(
imagePadding: EdgeInsets.all(0),
boxDecoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color.fromRGBO(205, 193, 255, 1.0),
Color.fromARGB(255, 255, 79, 10),
Color.fromARGB(255, 255, 31, 31),
],
),
),
);
}
and this is how it looks, i want to make gradient color full screen. but, didn't work
Unfortunately, it's not possible to remove the white box because it's hardcoded in the introduction_screen source code.
But there's a workaround. Just wrap the IntroductionScreen with a Stack and set its globalBackgroundColor to Colors.transparent. Remove the decoration from the PageViewModels. Then, add a Container with the desired decoration as the first widget in the Stack to serve as the background. It's going to look like this:
This is the code snippet:
return Stack(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color.fromRGBO(205, 193, 255, 1.0),
Color.fromARGB(255, 255, 79, 10),
Color.fromARGB(255, 255, 31, 31),
],
),
),
),
IntroductionScreen(
...
I have implemented a linear graph using the below code. I use charts flutter package.. the first image shows the graph I created. the second image shows what I need to be implemented I want to add another two lines for the same graph with different data values. how can I do this? appreciate your help on this. I use hardcoded values for the graph.
developer_series.dart
import 'package:charts_flutter/flutter.dart' as charts;
class DeveloperSeries {
final int day;
final int calories;
final charts.Color barColor;
DeveloperSeries(
{
required this.day,
required this.calories,
required this.barColor
}
);
}
developer_chart.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'developer_series.dart';
class DeveloperChart extends StatelessWidget {
final List<DeveloperSeries> data;
DeveloperChart({required this.data});
#override
Widget build(BuildContext context) {
List<charts.Series<DeveloperSeries,int>> series = [
charts.Series(
id: "calories",
data: data,
domainFn: (DeveloperSeries series, _) => series.day,
measureFn: (DeveloperSeries series, _) => series.calories,
colorFn: (DeveloperSeries series, _) => series.barColor
)
];
return Container(
height: 700,
// padding: EdgeInsets.all(25),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(40),
//
// ),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
color: Colors.grey.withOpacity(0.4),
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only( top: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
height: 30,
width: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [
Color.fromRGBO(125, 158, 205, 1.0),
Color.fromRGBO(158, 125, 243, 0.7490196078431373),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
child: TextButton(onPressed:() {},
child: const Text('Daily', style: TextStyle(color: Colors.white),),
),
),
Container(
height: 30,
width: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [
Color.fromRGBO(125, 158, 205, 1.0),
Color.fromRGBO(158, 125, 243, 0.7490196078431373),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
child: TextButton(onPressed:() {},
child: const Text('Week', style: TextStyle(color: Colors.white),),
),
),
Container(
height: 30,
width: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [
Color.fromRGBO(125, 158, 205, 1.0),
Color.fromRGBO(158, 125, 243, 0.7490196078431373),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
child: TextButton(
onPressed:() {},
child: const Text('Month', style: TextStyle(color: Colors.white),),
),
),
],
),
),
Expanded(
child: charts.LineChart(series,
animate: true,
domainAxis: const charts.NumericAxisSpec(
renderSpec: charts.GridlineRendererSpec(
labelStyle: charts.TextStyleSpec(
fontSize: 10,
color: charts.MaterialPalette.white,
),
lineStyle: charts.LineStyleSpec(
color: charts.MaterialPalette.transparent,
)),
tickProviderSpec:
charts.BasicNumericTickProviderSpec(zeroBound: false),
// viewport: charts.NumericExtents(2016.0, 2022.0),
),
primaryMeasureAxis: new charts.NumericAxisSpec(
renderSpec: charts.GridlineRendererSpec(
// labelOffsetFromAxisPx: -20,
// labelAnchor: charts.TickLabelAnchor.after,
lineStyle: charts.LineStyleSpec(
color: charts.MaterialPalette.white,
thickness: 1,
)
),
),
),
),
],
),
),
),
);
}
}
graph_calories.dart
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'developer_chart.dart';
import 'developer_series.dart';
class GraphDisplayCalories extends StatefulWidget {
#override
State<GraphDisplayCalories> createState() => _GraphDisplayCaloriesState();
}
class _GraphDisplayCaloriesState extends State<GraphDisplayCalories> {
final List<DeveloperSeries> data = [
DeveloperSeries(
day: 2017,
calories: 40000,
barColor: charts.ColorUtil.fromDartColor(Colors.purple),
),
DeveloperSeries(
day: 2018,
calories: 10000,
barColor: charts.ColorUtil.fromDartColor(Colors.purple),
),
DeveloperSeries(
day:2019,
calories: 20000,
barColor: charts.ColorUtil.fromDartColor(Colors.purple),
),
DeveloperSeries(
day: 2020,
calories: 35000,
barColor: charts.ColorUtil.fromDartColor(Colors.purple),
),
DeveloperSeries(
day: 2021,
calories: 20000,
barColor: charts.ColorUtil.fromDartColor(Colors.purple),
),
];
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: DeveloperChart(
data: data,
)
),
);
}
}
I would like to fade a LinearGradient into a different LinearGradient with different colors when I press a button, e.g. from
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
stops: [0.1, 0.5, 0.7, 0.9],
colors: [
Colors.blue[700],
Colors.blue[600],
Colors.blue[500],
Colors.blue[300],
],
)),
),
to
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
stops: [0.1, 0.5, 0.7, 0.9],
colors: [
Colors.red[700], // different color
Colors.red[600],
Colors.red[500],
Colors.red[300],
],
)),
),
How can I do this?
you can use AnimatedContainer to do so.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
List<Color> change = [Colors.blue[700],Colors.blue[600],Colors.blue[500],Colors.blue[300]];
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.transparent,
body: InkWell(
onTap: (){
change[0] = Colors.red[700];
change[1] = Colors.red[600];
change[2] = Colors.red[500];
change[3] = Colors.red[300];
},
child: AnimatedContainer(
child: Center(child: new Text("hello")),
duration: Duration(seconds: 5),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
stops: [0.1, 0.5, 0.7, 0.9],
colors: [
change[0],
change[1],
change[2],
change[3],
],
),
),
),
),
),
);
}
}
The simplest solution would be to assign some kind of state for the button, make the Container an AnimatedContainer and add a conditional to the decoration parameter. Something like the class I created for this question. In it I've made your stops and color lists constants, which allow your gradients to be constant as well. Then you pass a "text" argument and then you optionally have an onPressed callback that will tell you what its state is. I made this a class so to avoid letting the setState get called for the entire parent widget and the constants were given to exemplify good practices. Try to avoid placing these kinds of things in build methods.
const _stops = [0.1, 0.5, 0.7, 0.9];
const _redColors = [
Color(0xFFD32F2F), // different color
Color(0xFFE53935),
Color(0xFFF44336),
Color(0xFFE57373),
];
const _blueColors = [
Color(0xFF1976D2),
Color(0xFF1E88E5),
Color(0xFF2196F3),
Color(0xFF64B5F6),
];
const _red = const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
stops: _stops,
colors: _redColors,
)
);
const _blue = const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
stops: _stops,
colors: _blueColors,
)
);
class RedBlueButton extends StatefulWidget {
final Function(bool) onPressed;
final String text;
final String submittedText;
const RedBlueButton({Key key, this.onPressed, this.text, this.submittedText}) : super(key: key);
#override
_RedBlueButtonState createState() => _RedBlueButtonState();
}
class _RedBlueButtonState extends State<RedBlueButton> {
bool pressed = false;
#override
Widget build(BuildContext context) {
return InkWell(
onTap: (){
setState(() {
pressed = !pressed;
if(widget.onPressed != null)
widget.onPressed(pressed);
});
},
child: AnimatedContainer(
duration: kThemeChangeDuration,
decoration: pressed ? _red : _blue,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 5
),
child: Text(
pressed ? widget.text ?? 'submit' : widget.submittedText ?? 'sent',
style: TextStyle(
color: Colors.white
),
),
),
);
}
}