A simple benchmark of jogboms/registry.dart vs MelbourneDeveloper/ioc_container vs fluttercommunity/get_it for educational purposes
get_it -> 7.6.0
ioc_container -> 1.0.12
registry -> https://github.com/jogboms/registry.dart/commit/c93055554a589cc8e8b03b7ff35502438cfc235f
class CustomTrianglePainter extends CustomPainter { | |
final Color color; | |
late Paint _paint; | |
CustomTrianglePainter(this.color) { | |
_paint = Paint() | |
..color = color | |
..style = PaintingStyle.fill; | |
} |
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override |
// MIT License | |
// | |
// Copyright (c) 2022 Mike Rydstrom | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
// MIT License | |
// | |
// Copyright (c) 2022 Simon Lightfoot | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
// MIT License | |
// | |
// Copyright (c) 2022 Mike Rydstrom | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
This gist demonstrates jank observed during a large filesystem operation. There is a lint called avoid_slow_async_io
that recommends people not use async io methods. These methods are definitely slower than the sync methods, but they provide concurrency which is critical to a Flutter application. We are exploring if the linter recommendation introduces jank in a flutter app or not.
If you use sync io methods that are of moderate to large size, it will freeze the ui.
If you use the linter recommendations, the result is nearly identical to using async methods as a default. I have seen some dropped frames on Simulator but it's barely noticable.
import 'universal_platform_web.dart' | |
if (dart.library.io) 'universal_platform_vm.dart'; | |
/// A universal platform checker. | |
/// | |
/// Can be used to check active physical Flutter platform on all platforms. | |
/// | |
/// To check what host platform the app is running on use: | |
/// | |
/// * PlatformIs.android |
import 'dart:async' show Future; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart' show rootBundle; | |
import 'package:flutter_svg/flutter_svg.dart'; | |
/// Displays an SVG image provided in the applications asset bundle. | |
/// | |
/// The [assetName] is the path and name of the SVG file in the asset bundle. | |
/// This SVG asset display widget is tuned for usage with the Undraw images |