Search code examples
flutterdartcolorswidgetoperators

Adding extra option to tenerary operator flutter


   Container(
              decoration: BoxDecoration(
                  color: (page == _currentPage)
                      ? Colors.blue.shade800
                      : Colors.green.shade600
                      ),

I am trying to add another option to the tenerary operator since i have three pages that will change color. How can i add a third option


Solution

  • List<Color> colors = [Colors.blue, Colors.amber, Colors.pink];
    ...
    
    
    Container(
                  decoration: BoxDecoration(
                      color: colors[ _currentPage],