if (calText.length >= 1) { calText = calText.substring(0, calText.length - 1); } you should use this in setState(() {}); in statefulwidget