flutter_embrace 0.0.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

flutter_embrace #

Usage #

Embrace.initialize(); // for http logging

MaterialApp(
  navigatorObservers: [EmbraceRouteObserver()], // for view logging
);

More APIs for flutter: https://github.com/yongjhih/flutter_embrace/blob/master/lib/flutter_embrace.dart

Installation #

pubspec.yaml

dependencies:
  flutter_embrace:
    git:
      url: https://github.com/yongjhih/flutter_embrace.git

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

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

import 'package:flutter_embrace/flutter_embrace.dart';
import 'package:flutter_embrace/uris.dart';
import 'package:http/http.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    // you still need to put Embrace.getInstance().start(Application) in the Application#onCreate() for Android, for monitoring launching
    Embrace.initialize();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [EmbraceRouteObserver()],
      routes: <String, WidgetBuilder> {
        '/screen2': (BuildContext context) => Screen2(),
        '/screen3': (BuildContext context) => Screen3(),
      },
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreen createState() => _HomeScreen();
}

class _HomeScreen extends State<HomeScreen> {
  bool _isStarted;
  Client _client;
  String _body;

  @override
  void initState() {
    super.initState();
    _client = Client();

    Future.delayed(Duration.zero, () async {
      try {
        _isStarted = await Embrace.isStarted;
      } catch (err) {
      }
      try {
        final res = await _client.get("https://github.com/yongjhih/flutter_embrace/blob/master/lib/flutter_embrace.dart#L1");
        print("url: ${Uris.string(res.request.url)}");
        print("url.hasFragment: ${res.request.url.hasFragment}");
        print("url.fragment: ${res.request.url.fragment}");
        _body = res.body;
      } catch (err) {
        _body = "$err";
      }

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted) return;

      setState(() {
      });
    });
  }

  @override
  void dispose() {
    _client?.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SingleChildScrollView(child: Center(
          child: Column(
              children: [
                FlatButton(child: Text('Screen2'),
                  onPressed: () {
                    Navigator.of(context).pushNamed('/screen2');
                  },
                ),
                FlatButton(child: Text('Screen3'),
                  onPressed: () {
                    Navigator.of(context).pushNamed('/screen3');
                  },
                ),
                Text('isStarted: $_isStarted\n'),
                Text('$_body'),
              ]),
        )));
  }
}

class Screen2 extends StatefulWidget {
  @override
  _Screen2 createState() => _Screen2();
}

class _Screen2 extends State<Screen2> {
  Client _client;
  String _body;

  @override
  void initState() {
    super.initState();
    _client = Client();

    Future.delayed(Duration.zero, () async {
      try {
        final res = await _client.get("https://github.com/yongjhih/flutter_embrace/blob/master/lib/flutter_embrace.dart#L2");
        print("url: ${Uris.string(res.request.url)}");
        print("url.hasFragment: ${res.request.url.hasFragment}");
        print("url.fragment: ${res.request.url.fragment}");
        _body = res.body;
      } catch (err) {
        _body = "$err";
      }

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted) return;

      setState(() {
      });
    });
  }

  @override
  void dispose() {
    _client?.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
          appBar: AppBar(
            title: const Text('Screen2'),
          ),
          body: SingleChildScrollView(child: Center(
            child: Column(
                children: [
                  FlatButton(child: Text('Screen3'),
                    onPressed: () {
                      Navigator.of(context).pushNamed('/screen3');
                    },
                  ),
                  Text('$_body'),
                ]),
          ))
    );
  }
}

class Screen3 extends StatefulWidget {
  @override
  _Screen3 createState() => _Screen3();
}

class _Screen3 extends State<Screen3> {
  Client _client;
  String _body;

  @override
  void initState() {
    super.initState();
    _client = Client();

    Future.delayed(Duration.zero, () async {
      try {
        final res = await _client.get("https://github.com/yongjhih/flutter_embrace/blob/master/lib/flutter_embrace.dart#L3");
        print("url: ${Uris.string(res.request.url)}");
        print("url.hasFragment: ${res.request.url.hasFragment}");
        print("url.fragment: ${res.request.url.fragment}");
        _body = res.body;
      } catch (err) {
        _body = "$err";
      }

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted) return;

      setState(() {
      });
    });
  }

  @override
  void dispose() {
    _client?.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Screen3'),
        ),
        body: SingleChildScrollView(child: Center(
          child: Column(
              children: [
                FlatButton(child: Text('Screen2'),
                  onPressed: () {
                    Navigator.of(context).pushNamed('/screen2');
                  },
                ),
                Text('$_body'),
              ]),
        ))
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_embrace: ^0.0.8

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:flutter_embrace/flutter_embrace.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]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:flutter_embrace/flutter_embrace.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flutter_embrace/flutter_embrace.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flutter_embrace/flutter_embrace.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flutter_embrace/flutter_embrace.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [flutter_embrace] that is in a package requiring null.

Health suggestions

Format lib/flutter_embrace.dart.

Run flutter format to format lib/flutter_embrace.dart.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Format lib/uris.dart.

Run flutter format to format lib/uris.dart.

Maintenance suggestions

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.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0 1.9.1
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test