svg_provider 1.0.1 copy "svg_provider: ^1.0.1" to clipboard
svg_provider: ^1.0.1 copied to clipboard

SVG Validation and Image Provider for SVG images from network, asset, file, package or raw string.

example/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('SVG Provider Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // Basic asset example
              Image(
                width: 100,
                height: 100,
                image: SvgProvider('assets/icon.svg'),
              ),

              const SizedBox(height: 20),

              // Network example with validation
              Image(
                width: 100,
                height: 100,
                image: SvgProvider(
                  'https://example.com/sample.svg',
                  source: SvgSource.network,
                  validationOptions: SvgValidationOptions.strict,
                ),
              ),

              const SizedBox(height: 20),

              // Raw SVG example with color
              Image(
                width: 100,
                height: 100,
                image: SvgProvider(
                  '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
                      <circle cx="50" cy="50" r="40" stroke="black" stroke-width="2" fill="currentColor" />
                    </svg>''',
                  source: SvgSource.raw,
                  color: Colors.blue,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
150
points
271
downloads

Publisher

verified publisherdartfoundry.com

Weekly Downloads

SVG Validation and Image Provider for SVG images from network, asset, file, package or raw string.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, flutter_svg, http

More

Packages that depend on svg_provider