Horje
how to use wrap widget in flutter Code Example
how to use wrap widget in flutter
class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _selectedButton = null;
  void setSelectedButton(int index) {
    setState(() {
      _selectedButton = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Wrap(children: [
          for (int i = 0; i < 10; i++)
            CustomElevatedButton(
                i,
                _selectedButton == null
                    ? Colors.red
                    : _selectedButton == i
                        ? Colors.red
                        : Colors.grey, () {
              setSelectedButton(i);
            }),
        ]),
      ),
    );
  }
}

class CustomElevatedButton extends StatelessWidget {
  final int number;
  final Color buttonColor;
  final void Function() onPressed;
  CustomElevatedButton(this.number, this.buttonColor, this.onPressed);
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(5.0),
      child: Column(
        children: <Widget>[
          ElevatedButton(
            onPressed: onPressed,
            child: Text(
              '${number + 1}',
              textAlign: TextAlign.center,
            ),
            style: ElevatedButton.styleFrom(
              shadowColor: Colors.grey,
              primary: buttonColor,
              minimumSize: Size(70, 70),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(15.0),
              ),
              textStyle: TextStyle(
                fontSize: 40,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
        ],
      ),
    );
  }
}





Whatever

Related
can interface have static methods Code Example can interface have static methods Code Example
excel sheet with drop down list Code Example excel sheet with drop down list Code Example
android add back button to toolbar Code Example android add back button to toolbar Code Example
print 2d array Code Example print 2d array Code Example
vue date filter component Code Example vue date filter component Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6