websafe_svg 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 92

websafe_svg #

Dart Publisher

A Flutter compatible library to handle SVGs for Android, iOS, and Web.

The color attribute currently only works on Flutter 1.19.0-1.0.pre or higher. At time of release, this was available in the dev channel.

Using the library #

Add the repo to your Flutter pubspec.yaml file.

dependencies:
  websafe_svg: <<version>> 

Then run...

flutter packages get

Supports #

  • asset
  • network
  • memory
  • string

Example #

import 'package:websafe_svg/websafe_svg.dart';

...
Widget build(BuildContext context) {
  return WebsafeSvg.asset(...);
}

[1.1.0] - June 1st, 2020 #

  • Switched from HtmlElementView to Image.network
  • Added an example app

[1.0.3] - April 28th, 2020 #

  • Version bump to test fixed GH Action

[1.0.2] - April 28th, 2020 #

  • Swapped the hard coded color replacement with a RegEx to be more versatile
  • Updated / fixed documentation

[1.0.1] - April 27th, 2020 #

  • Transferred to verified publisher

[1.0.0] - April 27th, 2020 #

  • Initial release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:websafe_svg_example/src/animation_page.dart';

import 'src/asset_svg_page.dart';
import 'src/memory_svg_page.dart';
import 'src/network_svg_page.dart';
import 'src/string_svg_page.dart';

void main() {
  runApp(MyApp());
}

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('WebsafeSvg Example'),
      ),
      body: ListView(
        children: [
          ListTile(
            onTap: () => Navigator.of(context).push(
              MaterialPageRoute(
                builder: (BuildContext context) => AnimationPage(),
              ),
            ),
            title: Text('Animation'),
          ),
          ListTile(
            onTap: () => Navigator.of(context).push(
              MaterialPageRoute(
                builder: (BuildContext context) => AssetSvgPage(),
              ),
            ),
            title: Text('Assets'),
          ),
          ListTile(
            onTap: () => Navigator.of(context).push(
              MaterialPageRoute(
                builder: (BuildContext context) => MemorySvgPage(),
              ),
            ),
            title: Text('Memory'),
          ),
          ListTile(
            onTap: () => Navigator.of(context).push(
              MaterialPageRoute(
                builder: (BuildContext context) => NetworkSvgPage(),
              ),
            ),
            title: Text('Network'),
          ),
          ListTile(
            onTap: () => Navigator.of(context).push(
              MaterialPageRoute(
                builder: (BuildContext context) => StringSvgPage(),
              ),
            ),
            title: Text('String'),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  websafe_svg: ^1.1.0

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:websafe_svg/websafe_svg.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
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]
92
Learn more about scoring.

We analyzed this package on Jul 9, 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:

  • websafe_svg that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 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.

Fix lib/src/platform/browser/browser_svg.dart. (-0.50 points)

Analysis of lib/src/platform/browser/browser_svg.dart reported 1 hint:

line 3 col 8: Unused import: 'package:convert/convert.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 (flutter_svg).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
convert ^2.1.1 2.1.1
flutter 0.0.0
flutter_svg ^0.17.4 0.17.4 0.18.0
http ^0.12.1 0.12.1
logging ^0.11.4 0.11.4
meta ^1.1.8 1.1.8 1.2.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
path 1.7.0
path_drawing 0.4.1
path_parsing 0.1.4
pedantic 1.9.0 1.9.1
petitparser 3.0.4
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 2.1.0-nullsafety
xml 3.7.0 4.2.0
Dev dependencies
flutter_test