desktop_lifecycle 0.1.1 copy "desktop_lifecycle: ^0.1.1" to clipboard
desktop_lifecycle: ^0.1.1 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"}');
        });
  }
}
29
likes
150
pub points
93%
popularity

Publisher

verified publishermixin.dev

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on desktop_lifecycle