Created
March 23, 2022 20:01
-
-
Save jonahwilliams/25e1c58e098493dcce5fbb7a7ef13dd8 to your computer and use it in GitHub Desktop.
Example benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/scheduler.dart'; | |
import 'package:flutter/services.dart'; | |
import 'package:vector_graphics/vector_graphics.dart'; | |
import 'package:flutter_svg/flutter_svg.dart' as svg; | |
void main() { | |
runApp(const MyHomePage()); | |
} | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({Key? key}) : super(key: key); | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
int _frames = 0; | |
void _pumpFrame(_) { | |
if (_frames > 25) { | |
return; | |
} | |
setState(() { | |
_frames += 1; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
SchedulerBinding.instance.addPostFrameCallback(_pumpFrame); | |
// return svg.SvgPicture.asset('assets/test.svg'); | |
return VectorGraphic( | |
bytesLoader: AssetBytesLoader( | |
assetName: 'assets/test.bin', | |
assetBundle: rootBundle, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment