import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart'; import 'package:flutter/material.dart'; typedef void CalculatorButtonTapCallback({String buttonText}); List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE]; List operationsRed = [Calculations.CLEAR]; class CalculatorButton extends StatelessWidget { CalculatorButton({this.text, @required this.onTap}); final String text; final CalculatorButtonTapCallback onTap; @override Widget build(BuildContext context) { return Expanded( child: Container( decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 1.2, ), ), child: FlatButton( onPressed: () => onTap(buttonText: text), child: Text( text, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w700, color: buildTextColor()), ), padding: const EdgeInsets.all(20), highlightColor: Colors.blueGrey[100], splashColor: Colors.blueAccent[100], color: buildMainColor(), ))); } buildMainColor() { if(operationsBlue.indexOf(text)>-1){ return primaryColor; } else if(operationsRed.indexOf(text)>-1){ return redColor; } return fillColor; } buildTextColor() { if(operationsBlue.indexOf(text)>-1){ return whiteColor; } else if(operationsRed.indexOf(text)>-1){ return whiteColor; } return Colors.black; } }