overlay_builder 1.1.0 copy "overlay_builder: ^1.1.0" to clipboard
overlay_builder: ^1.1.0 copied to clipboard

Overlay Builder is used to build overlays using declarative programming

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Overlay Builder Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(),
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {
  final _overlayWidget = GlobalKey<OverlayWidgetState>();
  final _overlayFullscreen = GlobalKey<OverlayWidgetState>();

  OverlayWidgetState get overlayWidgetController {
    return _overlayWidget.currentState!;
  }

  OverlayWidgetState get overlayFullscreenController {
    return _overlayFullscreen.currentState!;
  }

  void onTap() {
    overlayWidgetController.toggle();
    overlayFullscreenController.toggle();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Overlay Builder Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            OverlayBuilder(
              key: _overlayWidget,
              child: const Text('Overlay Builder Demo'),
              overlayChild: const Material(
                type: MaterialType.transparency,
                child: CircularProgressIndicator(),
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: OverlayBuilder(
        key: _overlayFullscreen,
        type: OverlayType.fullscreen,
        child: FloatingActionButton(
          onPressed: onTap,
          tooltip: 'Show Overlay',
          child: const Icon(Icons.zoom_out_map),
        ),
        overlayChild: const Material(
          type: MaterialType.transparency,
          child: Center(
            child: CircularProgressIndicator(
              valueColor: AlwaysStoppedAnimation(Colors.black),
            ),
          ),
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
5
likes
140
pub points
64%
popularity

Publisher

verified publishervegasdevelopments.com

Overlay Builder is used to build overlays using declarative programming

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on overlay_builder