Closed joelbrostrom closed 5 years ago
Is this plugin no longer supported?
Yes, it's still supported. Could you add a minimum sample code to reproduce the issue please?
Something like:
class PagerState extends State<MyPager> {
PageController _pageController = PageController();
List<PageData> pages;
double _progress;
@override
Widget build(BuildContext context) {
return Column(children: [
PageView.builder(
key: PageStorageKey('Questionnarie'),
controller: _pageController,
itemCount: pages.length,
itemBuilder: (context, index) {
return SomePage(pages[index]);
},
onPageChanged: (index) {
setState(() {
_progress = index / pages.length;
});
}),
LinearPercentIndicator(
alignment: MainAxisAlignment.center,
width: MediaQuery.of(context).size.width - 50,
animation: true,
lineHeight: 15.0,
animationDuration: 1000,
percent: _progress,
animateFromLastPercent: true,
center: Text("${(100 * _progress).round()}%"),
linearStrokeCap: LinearStrokeCap.roundAll,
progressColor: Colors.greenAccent,
),
]);
}
}
When scrolling nextPage the animation continues from the previous value, but when scrolling to previous page it starts from 0 and animates to the new value.
Here, I made a better example app to illustrate the issue.
Just copy paste and add percent_indicator: ^1.0.13
to pubspec :)
import 'package:flutter/material.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(home: MyProgressBar());
}
class MyProgressBar extends StatefulWidget {
@override
State<StatefulWidget> createState() => MyProgressBarState();
}
class MyProgressBarState extends State<MyProgressBar> {
double _progress;
@override
void initState() {
super.initState();
_progress = 0.0;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: LinearPercentIndicator(
width: MediaQuery.of(context).size.width,
animation: true,
animateFromLastPercent: true,
percent: _progress,
)),
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FloatingActionButton(
child: Icon(Icons.remove),
onPressed: () {
setState(() {
_progress -= 0.1;
});
}),
FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
setState(() {
_progress += 0.1;
});
})
],
));
}
}
Thanks, I'll check this issue later today
On Fri, Mar 1, 2019 at 10:48 AM joel broström notifications@github.com wrote:
Here, I made a better example app to illustrate the issue. Just copy paste and add percent_indicator: ^1.0.13 to pubspec :)
import 'package:flutter/material.dart'; import 'package:percent_indicator/linear_percent_indicator.dart';
void main() => runApp(App());
class App extends StatelessWidget { @override Widget build(BuildContext context) => MaterialApp(home: MyProgressBar() ); }
class MyProgressBar extends StatefulWidget { @override State
createState() => MyProgressBarState(); } class MyProgressBarState extends State
{ double _progress; @override void initState() { super.initState(); _progress = 0.0; }
@override Widget build(BuildContext context) { return Scaffold( body: Center( child: LinearPercentIndicator( width: MediaQuery.of(context).size.width, animation: true, animateFromLastPercent: true, percent: _progress, )), floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.center, children:
[ FloatingActionButton( child: Icon(Icons.remove), onPressed: () { setState(() { _progress -= 0.1; }); }), FloatingActionButton( child: Icon(Icons.add), onPressed: () { setState(() { _progress += 0.1; }); }) ], )); } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/15#issuecomment-468710024, or mute the thread https://github.com/notifications/unsubscribe-auth/AEq90L_0o2BoF1L0DprxkyRPpfNot7LNks5vSUvXgaJpZM4a50DQ .
Sure, If you wan't I can take a look at it and if I figure it out I can send a PR. Do you accept contributions?
Of course, everyone who uses this package would appreciate it. Can you take a look the issue?
On Fri, Mar 1, 2019 at 10:50 AM joel broström notifications@github.com wrote:
Sure, If you wan't I can take a look at it and if I figure it out I can send a PR. Do you accept contributions?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/15#issuecomment-468710754, or mute the thread https://github.com/notifications/unsubscribe-auth/AEq90MjvteYhC_pos9QzhOm9L42TXhtBks5vSUxfgaJpZM4a50DQ .
I'm two beers in and the after work party starts in 1h 30m but I'll se what I can do :)
hahaha, have fun bro :)
On Fri, Mar 1, 2019 at 10:56 AM joel broström notifications@github.com wrote:
I'm two beers in and after work party starts in 1h 30m but I'll se what I can do :)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/15#issuecomment-468712707, or mute the thread https://github.com/notifications/unsubscribe-auth/AEq90LTFKu5_QQJnaTAcDF1_hMT8Gc7Hks5vSU2tgaJpZM4a50DQ .
I opened a PR with the fix for this issue. It was a tiny mistake, so there is not a lot to review. Great lib. Ty for the communication :)
awesome! thanks, it was merged
Can you push a new release with this fix? I need it in my project :)
Sure, but first, could you check the same issue for circular percent indicator?
On Tue, Mar 5, 2019 at 4:59 AM joel broström notifications@github.com wrote:
Can you push a new version (1.0.14) with this change? I need it in my project :)
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/15#issuecomment-469617423, or mute the thread https://github.com/notifications/unsubscribe-auth/AEq90GMSk05rdIrXplLv9NqdrAUrna_4ks5vTkAagaJpZM4a50DQ .
Done, sorry for the delay.
Thanks bro, it was published : 1.0.14
On Wed, Mar 6, 2019 at 10:59 AM joel broström notifications@github.com wrote:
Done, sorry for the delay.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/15#issuecomment-470163490, or mute the thread https://github.com/notifications/unsubscribe-auth/AEq90Cr6pLjNBf2uGz458dpn6r9Tm1m1ks5vT-XTgaJpZM4a50DQ .
When you increase the percentage with
animateFromLastPercent = true
the animation starts from the last value and ends at the new value. However when reducing the value the animation starts from 0 and ends at the new value.For example: 50% -> 75% animates from 50% to 75% 50% -> 25% animates from 0% to 25%
Is there support for reversing animation if
newValue < currentValue
?