OnBoarding buttons: Add keys

This way the flutter driver can easily find them even if the text
changes, which it probably will when I start localizing this app.
This commit is contained in:
Vishesh Handa
2019-02-16 12:28:54 +01:00
parent e5e60ef5db
commit 8aa92c4908

View File

@ -49,7 +49,11 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
if (_currentPageIndex != pages.length - 1) { if (_currentPageIndex != pages.length - 1) {
var row = Row( var row = Row(
children: <Widget>[ children: <Widget>[
OnBoardingBottomButton(text: "Skip", onPressed: _finish), OnBoardingBottomButton(
key: ValueKey("Skip"),
text: "Skip",
onPressed: _finish,
),
Expanded( Expanded(
child: Row( child: Row(
children: [ children: [
@ -62,7 +66,11 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
), ),
), ),
OnBoardingBottomButton(text: "Next", onPressed: _nextPage), OnBoardingBottomButton(
key: ValueKey("Next"),
text: "Next",
onPressed: _nextPage,
),
], ],
); );
@ -123,11 +131,16 @@ class OnBoardingBottomButton extends StatelessWidget {
final Function onPressed; final Function onPressed;
final String text; final String text;
OnBoardingBottomButton({@required this.text, @required this.onPressed}); OnBoardingBottomButton({
Key key,
@required this.text,
@required this.onPressed,
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FlatButton( return FlatButton(
key: key,
child: Text( child: Text(
text, text,
textAlign: TextAlign.center, textAlign: TextAlign.center,