floop_web 0.2.2

floop_web #

State management for Flutter. It's literally the same code as Floop, it just imports from package flutter_web instead of flutter.

https://pub.dev/packages/floop

Getting Started #

See more details on Github.

https://github.com/icatalud/floop/

Example - How to use #

+import 'package:floop_web/floop_web.dart';

-class Clicker extends StatelessWidget {
+class Clicker extends StatelessWidget with Floop {

  @override
-Widget build(BuildContext context) {
+Widget buildWithFloop(BuildContext context) {
buildWithFloop
    return Scaffold(
      body: Center(
+          child: Text(floop['clicks'].toString())
        ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
+        onPressed: () => floop['clicks']++    // change 'clicks' from anywhere in the app and the widget will get updated
      ),
    );
  }
}

On StatefulWidgets: ...extends State with FloopStateMixin.

Install #

Add floop dependency to your project's pubspec.yaml. Currently there are problems publishing flutter_web projects, because flutter_web does not exist on pub.dev. If adding the dependency like a regular pub.dev project does not work, try the following:

depedencies:
  floop:
    git: https://github.com/icatalud/floop
    path: packages/floop_web

Run flutter pub get in the root folder of your project.

[0.2.2] - 09/07/2019

Minor update to docs.

[0.2.1] - 09/07/2019

Minor updates to docs and example, change mixin name.

[0.2.0] - 09/07/2019

Publish flutter_web. It's exactly the same as floop but importing flutter_web library instead of flutter.

example/example.dart

import 'package:flutter_web/material.dart';
import 'package:floop_web/floop_web.dart';

/// This example exists solely to satisfy dart publishing requirements.
/// The real examples folder lies at the root of the project on Github.
/// https://github.com/icatalud/floop

void main() {
  floop['clicks'] = 0;
  runApp(MaterialApp(
      title: 'Clicker',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Clicker()));
}

class Clicker extends StatelessWidget with Floop {
  @override
  Widget buildWithFloop(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text(
          floop['clicks'].toString(),
          style: TextStyle(
            color: Colors.red,
            fontSize: 100,
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add), onPressed: () => floop['clicks']++),
    );
  }
}

// The following are alternative implementations.

class ClickerStateful extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => ClickerState();
}

class ClickerState extends State<ClickerStateful> with FloopStateMixin {
  @override
  Widget buildWithFloop(BuildContext context) {
    return Scaffold(
      body: Center(
          child: Text(floop['clicks'].toString(),
              style: TextStyle(
                color: Colors.red,
                fontSize: 100,
              ))),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add), onPressed: () => floop['clicks']++),
    );
  }
}

// Simplest example.

class SimpleClicker extends StatelessWidget with Floop {
  @override
  Widget buildWithFloop(BuildContext context) {
    return Scaffold(
      body: Center(child: Text(floop['clicks'].toString())),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add), onPressed: () => floop['clicks']++),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  floop_web: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


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

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms:

Low code quality prevents platform classification.

Health issues and suggestions

Fix lib/src/controller.dart. (-100 points)

Analysis of lib/src/controller.dart failed with 35 errors, 1 hint, including:

line 9 col 25: Undefined class 'Element'.

line 32 col 3: Undefined class 'Element'.

line 35 col 3: Undefined class 'Element'.

line 43 col 3: Undefined name 'mustCallSuper' used as an annotation.

line 44 col 33: Undefined class 'Element'.

Fix lib/src/mixins.dart. (-100 points)

Analysis of lib/src/mixins.dart failed with 42 errors, 6 hints, including:

line 1 col 8: Target of URI doesn't exist: 'package:meta/meta.dart'.

line 7 col 16: Only classes and mixins can be used as super-class constraints.

line 7 col 16: Undefined class 'StatelessWidget'.

line 10 col 3: Undefined class 'Widget'.

line 10 col 25: Undefined class 'BuildContext'.

Fix lib/src/flutter_import.dart. (-25 points)

Analysis of lib/src/flutter_import.dart failed with 1 error:

line 1 col 8: Target of URI doesn't exist: 'package:flutter_web/widgets.dart'.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Low code quality prevents platform classification.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
Dev dependencies
build_runner ^1.5.0
build_web_compilers ^2.1.0
flutter_web
flutter_web_test
flutter_web_ui
mockito any
pedantic ^1.7.0