vector_graphics_plus 1.1.13 copy "vector_graphics_plus: ^1.1.13" to clipboard
vector_graphics_plus: ^1.1.13 copied to clipboard

discontinuedreplaced by: vector_graphics

A vector graphics rendering package for Flutter.

example/lib/main.dart

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:developer';

import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:vector_graphics_plus/vector_graphics.dart';
import 'package:vector_graphics_compiler_plus/vector_graphics_compiler.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Vector Graphics Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const Scaffold(
        body: Center(
          child: VectorGraphic(
            loader: NetworkSvgLoader(
              'https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg',
            ),
          ),
        ),
      ),
    );
  }
}

class NetworkSvgLoader extends BytesLoader {
  const NetworkSvgLoader(this.url);

  final String url;

  @override
  Future<ByteData> loadBytes(BuildContext? context) async {
    return await compute((String svgUrl) async {
      final http.Response request = await http.get(Uri.parse(svgUrl));
      final TimelineTask task = TimelineTask()..start('encodeSvg');
      final Uint8List compiledBytes = encodeSvg(
        xml: request.body,
        debugName: svgUrl,
        enableClippingOptimizer: false,
        enableMaskingOptimizer: false,
        enableOverdrawOptimizer: false,
      );
      task.finish();
      // sendAndExit will make sure this isn't copied.
      return compiledBytes.buffer.asByteData();
    }, url, debugLabel: 'Load Bytes');
  }

  @override
  int get hashCode => url.hashCode;

  @override
  bool operator ==(Object other) {
    return other is NetworkSvgLoader && other.url == url;
  }
}
0
likes
150
points
1.03k
downloads

Publisher

verified publishermariuti.com

Weekly Downloads

A vector graphics rendering package for Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, http, vector_graphics_codec

More

Packages that depend on vector_graphics_plus