Reputation: 21
i think sometimes it is required to handle variables inside @override build method.
@override
Widget build(BuildContext context) {
Animation animationTitle1 = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController,
curve: Interval(0, 1.0, curve: Curves.fastOutSlowIn)));
Animation animationTitle2 = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: widget.animationController,
curve: Interval(0.2, 1.0, curve: Curves.fastOutSlowIn)));
.
.
.
i don't know it is logically efficient or not ? but somehow i need this kind of logic to declare and manage multiple variables inside @build method. some requirements like
example like
@override
Widget build(BuildContext context) {
var streamBuilder = StreamBuilder(
stream: myStreamObj,
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshotVacchan) {
// my code
},
);
return Column(
children: [
streamBuilder,
FlatButton(
child: Text('Reload'),
onPressed: () {
setState(() {
myStreamObj = newScreen;
});
}),
],
);
}
Upvotes: 1
Views: 496
Reputation: 245
According to my knowledge, it is not the proper way of coding to declare or manage variables inside the build method.
Upvotes: 1