frebu 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

Frebu #

Frebu (flutter repository builder) is a package to help maintain code on data layer.

[0.1.1] #

  • Add abstraction for common results

[0.1.0] #

  • Add example

[0.0.1] #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:frebu_example/in_memory_repository.dart';

import 'note.dart';
import 'repository.dart';

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

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

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

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

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController controller;
  NotesRepository repository;

  @override
  void initState() {
    super.initState();
    controller = TextEditingController();
    repository = InMemoryNotesRepository();
    repository.execute(FetchNotes());
  }

  @override
  void dispose() {
    controller.dispose();
    repository.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Notes')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Expanded(
                child: StreamBuilder<List<Note>>(
                    stream: repository.notesStream,
                    initialData: [],
                    builder: (context, snapshot) {
                      final notes = snapshot.data;
                      return ListView.builder(
                        itemCount: notes.length,
                        itemBuilder: (context, i) => ListTile(
                          title: Text(notes[i].message),
                        ),
                      );
                    })),
            Divider(),
            TextField(
              controller: controller,
              textInputAction: TextInputAction.next,
              onSubmitted: (message) {
                repository.execute(AddNote(message));
                controller.clear();
              },
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  frebu: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:frebu/frebu.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
20
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-1 points)

119 out of 119 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/frebu.dart.

Run flutter format to format lib/frebu.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (rxdart).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
meta ^1.1.7 1.1.8
rxdart ^0.22.0 0.22.6 0.23.1
Dev dependencies
flutter_test
mockito ^4.1.1
pedantic ^1.5.0