bitsdojo / bitsdojo_window

A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
http://www.youtube.com/watch?v=bee2AHQpGK4
MIT License
816 stars 229 forks source link

add Restore Icon #114

Open greatsam4sure opened 3 years ago

greatsam4sure commented 3 years ago

on windows a typical window shows maximize icon when window is not maximize but after maximizing the window the icon changes to restore icon. Currently your package is using only maximize icon for both maximize and restore. It will be nice to change the maximize icon to restore icon after a the window is maximize. Thanks for this beautiful package

ankushmishra2903-official commented 3 years ago

i have also same issue and then i found solution to make my own maximize/restore, minimize, close icon button and moveable Title Bar here is my maximize/ restore button


class MaxMinButton extends StatefulWidget {
  const MaxMinButton({Key? key}) : super(key: key);

  @override
  _MaxMinButtonState createState() => _MaxMinButtonState();
}

class _MaxMinButtonState extends State<MaxMinButton> {

  @override
  void initState() {
    super.initState();
    Timer.periodic(Duration(milliseconds: 10), (Timer timer) {
      setState(() {});
    });
  }

  bool isMax() => appWindow.isMaximized;

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      style: ButtonStyle(
        elevation: MaterialStateProperty.all(0),
        backgroundColor: MaterialStateProperty.resolveWith<Color>(
            (Set<MaterialState> states) {
          if (states.contains(MaterialState.hovered)) {
            return Colors.grey.shade400;
          }
          return Colors.transparent;
        }),
      ),
      onPressed: () {
        appWindow.maximizeOrRestore();
      },
      child: Icon(
        isMax() ? Icons.close_fullscreen : Icons.open_in_full,
        color: Colors.white,
      ),
    );
  }
}

you can be change icon as you went