Closed minhnhatvdl closed 2 years ago
Can you add a minimum sample code to reproduce the issue?
On Fri, Oct 15, 2021, 6:34 PM minhnhatvdl @.***> wrote:
Hello,
I want to change progressColor when my process > 90 %. But actually, i cant do it. You have any ideal ?
Thank you very much
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/diegoveloper/flutter_percent_indicator/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFL3UEGJZCUGUXTLWAAFDDUHC3CFANCNFSM5GC6IJYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Yes, here is my code. I create a NameInput widget. When the length of this input pass over 90% percents of max length, i want to change a process color.
` import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:percent_indicator/percent_indicator.dart';
class NameInput extends StatefulWidget { const NameInput({ this.maxLength = 50, Key? key, }) : super(key: key); final int maxLength;
@override
State
class _NameInputState extends State
@override void initState() { super.initState(); _controller.addListener(() { setState(() { _percent = _controller.text.length / widget.maxLength; }); }); }
@override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context);
return SizedBox(
child: TextField(
controller: _controller,
focusNode: _focusNode,
cursorColor: theme.primaryColor,
maxLength: widget.maxLength,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Name',
counterText: '',
contentPadding: const EdgeInsets.all(10),
suffixIconConstraints:
const BoxConstraints(minWidth: 0, minHeight: 0),
suffixIcon: Container(
padding: const EdgeInsets.only(right: 20),
child: CircularPercentIndicator(
radius: 22,
lineWidth: 2.5,
animation: true,
percent: _percent,
backgroundColor: theme.dividerColor.withOpacity(0.2),
circularStrokeCap: CircularStrokeCap.round,
progressColor: _percent < 90 ? Colors.green : Colors.red,
animateFromLastPercent: true,
addAutomaticKeepAlive: false,
),
),
prefixIconConstraints:
const BoxConstraints(minWidth: 0, minHeight: 0),
prefixIcon: Container(
width: 130,
padding: const EdgeInsets.only(left: 20),
child: Text(
'Name',
style: theme.textTheme.bodyText2!.copyWith(
fontWeight: FontWeight.w600,
),
),
),
),
),
);
}
@override void dispose() { super.dispose(); _controller.dispose(); } }
`
the percent
value is not 90, is 0.9
Hello,
I want to change progressColor when my process > 90 %. But actually, i cant do it. You have any ideal ?
Thank you very much