stack_overlay 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new57

StackOverlay Widget plugin for Flutter

StackOverlay is a widget that will uses 2 stacked screens(widgets). The foreground widget is overlayed over the background one and can be hidden or shown depending on a boolean value passed to the StackOverlay widget, just take a look at the example for more details.

Originally designed to provide as a way of forcing a "login" screen to automatically be shown should a user not be logged in(to whatever service) then dismissed once the user has logged in.

The widget takes 3 values

  • background - this is the background widget (usually the main screen)
  • foreground - this is the dismissable foreground widget( for example a Login screen)
  • showForeground - a boolean to indicate if the foreground widget should be shown or hidden (defaults to false if not provided)

Demo Screen

More info can be found here.

Using StackOverlay

Take a look at the plugin installation instructions.

Getting Started

For help getting started with Flutter, view the online documentation.

[0.0.3] - 12 August 2018

  • Documentation updates.

[0.0.2] - 12 August 2018

  • update environment to indicate Dart 2 support.

[0.0.1] - 12 August 2018

  • initial release.

example/lib/main.dart

/// Demo of StackOverlay showing a dismissable Login Screen 
/// the login screen can be forced to show on start up or displayed using a button.
/// 
/// In the demo this uses a bool called [showOverlay] but this could come
/// from a stored shared_preference to indicate if the user needs to login 
/// before continuing with the app

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


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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      title: "Stack Overlay Example",
      home: OverlayApp()
    );
  }
}

/// A demo of the StackOverlay Widget
class OverlayApp extends StatefulWidget {
  @override
  _OverlayAppState createState() => _OverlayAppState();
}

class _OverlayAppState extends State<OverlayApp> {

  // initial state of the foreground overlay 
  // this will force the login screen to be displayed - change to false to hide by default
  bool showOverlay = true; 

  @override
  Widget build(BuildContext context) {
    return StackOverlay(

      // determine if foreground should be shown
      showForeground: showOverlay,

      // our dismissible foreground widget
      foreground: _LoginScreen(
        onFinish: () {
          // TODO:: do login stuff here
          setState(() {
            // dismiss the login overlay
            showOverlay = false;
          });
          }
      ),

      // our background widget
      background: _BackgroundScreen(
        onLogin: () {
          setState(() {
            // show the login screen
            showOverlay = true;
          });       
        },
      ),

    );
  }

}


/// demo [background] widget
class _BackgroundScreen extends StatelessWidget {

  final Function onLogin;

  _BackgroundScreen({@required this.onLogin});

  @override build(BuildContext context){
    return Scaffold(
      appBar: AppBar(
        title: Text("StackOverlay Demo"),
        actions: <Widget>[
          IconButton(
          onPressed: onLogin,
          icon: Icon(Icons.person),
        )

        ],
      ),
    );
  }

}


/// demo login screen used for our [foreground] widget
class _LoginScreen extends StatelessWidget {

  final Function onFinish;

  _LoginScreen({@required this.onFinish});

  @override
  Widget build(BuildContext context) {
    return Container(
        color: Colors.blueAccent,
        padding: EdgeInsets.fromLTRB(30.0, 100.0, 30.0, 100.0),
        child: SafeArea(
          child: Scaffold(
            backgroundColor: Colors.blueAccent,
            body: ListView(
              children: <Widget>[
                Text(
                  "Dummy User Login",
                  style: TextStyle( color: Colors.white, fontSize: 20.0)
                ),
                SizedBox(height: 20.0),
                TextField(
                  decoration: InputDecoration(hintText: "username or email"),
                ),
                TextField(
                  decoration: InputDecoration(hintText: "password"),
                ),  
                SizedBox(height: 20.0),
                RaisedButton(
                  onPressed: onFinish,
                  child: Text("Login"),
                )
              ],
            )
          )
        )
    );
  }

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stack_overlay: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stack_overlay/stack_overlay.dart';
  
Version Uploaded Documentation Archive
0.0.3 Aug 12, 2018 Go to the documentation of stack_overlay 0.0.3 Download stack_overlay 0.0.3 archive
0.0.2 Aug 12, 2018 Go to the documentation of stack_overlay 0.0.2 Download stack_overlay 0.0.2 archive
0.0.1 Aug 12, 2018 Go to the documentation of stack_overlay 0.0.1 Download stack_overlay 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

We analyzed this package on Aug 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8
  • Flutter: 0.5.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/stack_overlay.dart.

Run flutter format to format lib/stack_overlay.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.8
Dev dependencies
flutter_test