globalui 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

globalui #

A pure Flutter UI Manager Library.

Show UI without context

Usage #

1. Add library to your pubspec.yaml #

dependencies:
  globalui: ^2.3.1 # such as version, you need use the latest version of pub.

2. Import library in root file #

import 'package:globalui/globalui.dart';

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

3. Use Wrapper to Wrap #

class MyApp extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
    return GuiWrapper(
        child: MaterialApp(
          ...
        )
    );
  }

}

if user want to use custom style to override default, Lib offer some themes;

class MyApp extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
    return GuiWrapper(
         toastTheme: ToastTheme(
              textStyle: TextStyle(color: Colors.red, fontSize: 20.0)
      ),
      modalTheme: ModalTheme(
              .....
      ),
        child: MaterialApp(
          ...
        )
    );
  }

}

4. Show UI Without context #

Currently, We offer two kind of UI:

toast like

will hide themselves in seconds

showToast("tast");

Widget widget = Container(.....)

showToastWidget(widget);

modal like

will hide themselves by user action

showCancelConfirmModal(
                    title: "testTitle",
                    msg: "测试消息",
                    cancelText: "BYE",
                    onCancelPressed: () {
                      print("click cancel");
                    },
                    confirmText: "Hi",
                    confirmTextStyle: TextStyle(color: Colors.white, fontSize: 15.0),
                    confirmBackgroundColor: Colors.red,
                    onConfirmPressed: () {
                      print("click confirm");
                    },
                  );
showCancelModal(
                    title: "测试标题",
                    msg: "测试消息",
                    onCancelPressed: () {
                      print("showCancelModal");
                    });

Widget widget = Container(.....)

showModalWidget(widget);

[0.0.1] - TODO: Add release date. #

  • TODO: Init

[0.0.2] - TODO: Add release date. #

  • fix default modal style,Add Shadow

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:globalui/globalui.dart'; // 1. import library
import 'dart:math' as math;

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GuiWrapper(
        toastTheme: ToastTheme(
            textStyle: TextStyle(color: Colors.red, fontSize: 20.0)
      ),
        child: MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    ));
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    //showToast("tast");
    showCancelModal(
        title: "测试标题",
        msg: "测试消息",
        onCancelPressed: () {
          print("showCancelModal");
        });
  }

  // Future<bool> _onBackPressed() {
  //       return showDialog(
  //           context: context,
  //           builder: (context) =>
  //               AlertDialog(
  //                   title: Text('确定退出程序吗?'),
  //                   actions: <Widget>[
  //                       FlatButton(
  //                           child: Text('暂不'),
  //                           onPressed: () => Navigator.pop(context, false),
  //                       ),
  //                       FlatButton(
  //                           child: Text('确定'),
  //                           onPressed: () => Navigator.pop(context, true),
  //                       ),
  //                   ],
  //               ));
  //   }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    // return WillPopScope(
    //       onWillPop: _onBackPressed,
    //         child:Scaffold(

      return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            FlatButton(
              color: getRandomColor(),
              onPressed: () {
                showToast("tast");
              },
              child: Text("Toast",
                  style:
                      TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0)),
            ),
            FlatButton(
               color: getRandomColor(),
              onPressed: () {
                showCancelModal(
                    title: "测试标题",
                    msg: "测试消息",
                    onCancelPressed: () {
                      print("showCancelModal");
                    });
              },
              child: Text("one button modal",
                  style:
                      TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0)),
            ),
            FlatButton(
               color: getRandomColor(),
               onPressed: () {
                showCancelConfirmModal(
                    title: "testTitle",
                    msg: "测试消息",
                    cancelText: "BYE",
                    onCancelPressed: () {
                      print("click cancel");
                    },
                    confirmText: "Hi",
                    confirmTextStyle: TextStyle(color: Colors.white, fontSize: 15.0),
                    confirmBackgroundColor: Colors.red,
                    onConfirmPressed: () {
                      print("click confirm");
                    },
                  );
                    
              },
              child: Text("two button modal",
                  style:
                      TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0)),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  Color getRandomColor() {
    return Color((math.Random().nextDouble() * 0xFFFFFF).toInt() << 0).withOpacity(1.0);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  globalui: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:globalui/globalui.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • globalui that is a package requiring null.

Health suggestions

Fix lib/widget/overlay.dart. (-0.50 points)

Analysis of lib/widget/overlay.dart reported 1 hint:

line 578 col 8: This method overrides a method annotated as '@mustCallSuper' in 'Element', but doesn't invoke the overridden method.

Format lib/core/gui_future.dart.

Run flutter format to format lib/core/gui_future.dart.

Format lib/core/gui_manager.dart.

Run flutter format to format lib/core/gui_manager.dart.

Fix additional 12 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/core/gui_position.dart (Run flutter format to format lib/core/gui_position.dart.)
  • lib/globalui.dart (Run flutter format to format lib/globalui.dart.)
  • lib/widget/animation/animation_builder.dart (Run flutter format to format lib/widget/animation/animation_builder.dart.)
  • lib/widget/animation/miui10_builder.dart (Run flutter format to format lib/widget/animation/miui10_builder.dart.)
  • lib/widget/animation/offset_builder.dart (Run flutter format to format lib/widget/animation/offset_builder.dart.)
  • lib/widget/gui_container.dart (Run flutter format to format lib/widget/gui_container.dart.)
  • lib/widget/gui_theme.dart (Run flutter format to format lib/widget/gui_theme.dart.)
  • lib/widget/gui_wrap.dart (Run flutter format to format lib/widget/gui_wrap.dart.)
  • lib/widget/modal/modal_func.dart (Run flutter format to format lib/widget/modal/modal_func.dart.)
  • lib/widget/modal/modal_theme.dart (Run flutter format to format lib/widget/modal/modal_theme.dart.)
  • lib/widget/toast/toast_func.dart (Run flutter format to format lib/widget/toast/toast_func.dart.)
  • lib/widget/toast/toast_theme.dart (Run flutter format to format lib/widget/toast/toast_theme.dart.)

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: Documenting globalui... Initialized dartdoc with 517 libraries in 93.4 seconds Generating docs for library animation_builder from package:globalui/widget/animation/animation_builder.dart... Generating docs for library globalui from package:globalui/globalui.dart... Generating docs for library globalui from package:globalui/core/gui_core.dart... Generating docs for library gui_position from package:globalui/core/gui_position.dart... Generating docs for library miui10_builder from package:globalui/widget/animation/miui10_builder.dart... Generating docs for library offset_builder from package:globalui/widget/animation/offset_builder.dart... Generating docs for library opacity_builder from package:globalui/widget/animation/opacity_builder.dart... Generating docs for library overlay from package:globalui/widget/overlay.dart... Validating docs... Documented 8 public libraries in 16.0 seconds stderr: warning: globalui has no library level documentation comments, from globalui: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/globalui.dart:1:9) warning: globalui has no library level documentation comments, from globalui: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/core/gui_core.dart:1:9) error: failed to write file at: globalui/globalui-library.html for symbol globalui: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/core/gui_core.dart:1:9) conflicting with file already generated by globalui: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/globalui.dart:1:9) Dartdoc generates a path and filename to write to for each symbol. globalui conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. warning: unresolved doc reference [CupertinoApp] from globalui.GuiWrapper.child: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/gui_wrap.dart:5:18) in documentation inherited from globalui.GuiWrapper.child: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/gui_wrap.dart:5:18) warning: unresolved doc reference [MaterialApp], from overlay.Overlay: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:190:7) warning: unresolved doc reference [MaterialApp], from overlay.OverlayEntry: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:51:7) warning: unresolved doc reference [MaterialApp], from overlay.Overlay.Overlay: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:198:9) warning: unresolved doc reference [InheritedWidget] from overlay.OverlayState.build: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:447:10) in documentation inherited from framework.State.build: (file:///flutter/packages/flutter/lib/src/widgets/framework.dart:1413:10) warning: unresolved doc reference [AnimatedWidget] from overlay.OverlayState.build: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:447:10) in documentation inherited from framework.State.build: (file:///flutter/packages/flutter/lib/src/widgets/framework.dart:1413:10) warning: unresolved doc reference [int] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [DiagnosticsTreeStyle] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [ColorProperty] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [Color] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [IconDataProperty] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [IconData] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [TransformProperty] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) warning: unresolved doc reference [Matrix4] from overlay.OverlayState.debugFillProperties: (file:///tmp/pub-dartlang-dartdocMJPDQL/pkg/lib/widget/overlay.dart:474:8) in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///flutter/packages/flutter/lib/src/foundation/diagnostics.dart:3366:8) found 16 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:225:9)

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test