desktop_lifecycle 0.1.0 icon indicating copy to clipboard operation
desktop_lifecycle: ^0.1.0 copied to clipboard

Allow your flutter desktop application to perceive whether the window is activated.

example/lib/main.dart

import 'package:desktop_lifecycle/desktop_lifecycle.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: const [
            FocusLifecycleState(),
          ],
        ),
      ),
    );
  }
}

class FocusLifecycleState extends StatelessWidget {
  const FocusLifecycleState({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
        animation: DesktopLifecycle.instance.isActive,
        builder: (context, child) {
          final active = DesktopLifecycle.instance.isActive.value;
          return Text('active: ${active ? "active" : "inactive"}');
        });
  }
}
13
likes
130
pub points
91%
popularity

Publisher

verified publisher iconmixin.dev

Allow your flutter desktop application to perceive whether the window is activated.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on desktop_lifecycle