flutter_kanjivg 0.1.0 copy "flutter_kanjivg: ^0.1.0" to clipboard
flutter_kanjivg: ^0.1.0 copied to clipboard

Flutter widgets that simplify displaying data from the Kanji Vector Graphics project. Built on the top of `kanjivg` package.

example/lib/main.dart

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

void main() {
  return runApp(
    const MaterialApp(
      home: ExamplePage(),
    ),
  );
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage>
    with TickerProviderStateMixin {
  late final KanjiController controller = KanjiController(
    vsync: this,
    duration: const Duration(seconds: 3),
  );

  @override
  void initState() {
    super.initState();
    load();
  }

  Future<void> load() async {
    const parser = KanjiParser();

    // Loads a sample SVG file from assets (和 in this example).
    final bundle = DefaultAssetBundle.of(context);
    final kvg = await bundle.loadString('assets/0548c.svg');
    final data = parser.parse(kvg);

    controller
      ..load(data)
      ..forward();
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('flutter_kanjivg'),
      ),
      body: Center(
        child: Card(
          child: KanjiCanvas(
            size: 260,
            thickness: 8,
            controller: controller,
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        tooltip: 'Toggle',
        onPressed: controller.toggle,
        child: ListenableBuilder(
          listenable: controller,
          builder: (context, child) => controller.isAnimating
              ? const Icon(Icons.pause)
              : const Icon(Icons.play_arrow),
        ),
      ),
    );
  }
}
7
likes
160
pub points
45%
popularity
screenshot

Publisher

verified publishernikodembernat.com

Flutter widgets that simplify displaying data from the Kanji Vector Graphics project. Built on the top of `kanjivg` package.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, kanjivg, vector_graphics_compiler

More

Packages that depend on flutter_kanjivg