From 8aa92c49087700e5351f6f183a6c002a356cf5a1 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 16 Feb 2019 12:28:54 +0100 Subject: [PATCH] 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. --- lib/screens/onboarding_screens.dart | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/screens/onboarding_screens.dart b/lib/screens/onboarding_screens.dart index 3b82ef9f..0bee6511 100644 --- a/lib/screens/onboarding_screens.dart +++ b/lib/screens/onboarding_screens.dart @@ -49,7 +49,11 @@ class OnBoardingScreenState extends State { if (_currentPageIndex != pages.length - 1) { var row = Row( children: [ - OnBoardingBottomButton(text: "Skip", onPressed: _finish), + OnBoardingBottomButton( + key: ValueKey("Skip"), + text: "Skip", + onPressed: _finish, + ), Expanded( child: Row( children: [ @@ -62,7 +66,11 @@ class OnBoardingScreenState extends State { 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 String text; - OnBoardingBottomButton({@required this.text, @required this.onPressed}); + OnBoardingBottomButton({ + Key key, + @required this.text, + @required this.onPressed, + }) : super(key: key); @override Widget build(BuildContext context) { return FlatButton( + key: key, child: Text( text, textAlign: TextAlign.center,