61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:kanimaji/kanimaji/animate_kanji.dart';
|
|
|
|
void main() => runApp(const MyApp());
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({Key? key}) : super(key: key);
|
|
|
|
Future<String> generateGif() async {
|
|
await createAnimation(
|
|
kanji: '拝',
|
|
outputFile: '/tmp/kanji.gif',
|
|
);
|
|
return '/tmp/kanji.gif';
|
|
}
|
|
|
|
// void main(List<String> args) {
|
|
// // createAnimation('assets/kanjivg/kanji/0f9b1.svg');
|
|
|
|
// const kanji = '拝啓';
|
|
// // final fileList = [];
|
|
// for (int k = 0; k < kanji.length; k++) {
|
|
// // fileList.add('${k+1}.gif');
|
|
// }
|
|
|
|
// // File('index.html').writeAsStringSync(
|
|
// // '<html>' +
|
|
// // fileList.map((e) => File(e).readAsStringSync().replaceAll(']>', '')).join('\n') +
|
|
// // '</html>'
|
|
// // );
|
|
// // createAnimation(
|
|
// // inputFile: 'assets/kanjivg/kanji/060c5.svg',
|
|
// // outputFile: 'test.svg',
|
|
// // );
|
|
// }
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Kanimaji Demo',
|
|
theme: ThemeData(primarySwatch: Colors.blue),
|
|
home: FutureBuilder<String>(
|
|
future: generateGif(),
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) {
|
|
return ErrorWidget(snapshot.error.toString());
|
|
}
|
|
|
|
if (!snapshot.hasData) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
return Image.file(File(snapshot.data!));
|
|
},
|
|
));
|
|
}
|
|
}
|