Created
July 28, 2022 13:02
-
-
Save NinoBass/001790fd1d120dd01fa10624bdece1d9 to your computer and use it in GitHub Desktop.
Flutter inteview You’re making a shopping app called RubberBaby, which sells dolls. Unfortunately, you’ve run into a problem on the order page. If a customer makes one order for blue dolls and another order for red dolls but then tries to delete the blue doll order, the red doll order is wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderPage extends StatefulWidget { | |
@override | |
_OrderPageState createState() => _OrderPageState(); | |
} | |
class _OrderPageState extends State<OrderPage> { | |
bool isShowing = true; | |
@override | |
Widget build(BuildContext context) { | |
return Column(children: [ | |
RaisedButton( | |
child: (Text('Delete blue')), | |
onPressed: () { | |
setState(() { | |
isShowing = false; | |
}); | |
}, | |
), | |
if (isShowing) CounterButton(color: Colors.blue), | |
CounterButton(color: Colors.red), | |
]); | |
} | |
} | |
class CounterButton extends StatelessWidget { | |
final Color color; | |
const CounterButton({Key? key, required this.color}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
Size size = MediaQuery.of(context).size; | |
return Padding( | |
padding: const EdgeInsets.all(24.0), | |
child: Container( | |
width: size.width, | |
height: 55, | |
color: color, | |
child: (Text('0')), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment