Search code examples
fluttertextdiscount

show discount percent of product in Text Widget in flutter


I want to show amount of discount percent in Text widget in flutter, i used the Discount calculation formula but it didn't worked , How can i do that? this is what i want:

Container(
  decoration: BoxDecoration(
  color: Color(0xfff40725),
  borderRadius: BorderRadius.circular(50),
),

child: Padding(
  padding: const EdgeInsets.all(5.0),
  child: Text(
    '50% (but with formula',
    style: TextStyle(
      color: Colors.white, 
      fontWeight: FontWeight.bold),
    ),
  ),
),

Solution

  • You can use string substitution.

    Text("${your_formula()}%")