Flutter app slow

debug mode launch is slow blink when launch app size big. because debug mode with Hot reloads. when you create release apk https://flutter.io/docs/deployment/android you can find fast launch no blink during the launch app size small (but bigger than the normal android app) EDIT https://flutter.io/docs/testing/ui-performance#debug-flags Debug mode enables additional checks (such as asserts) that don’t … Read more

how can we use superscript and subscript text in flutter Text or RichText

You need to use Unicode. Here is the Unicode got from this answer: unicode_map = { # superscript subscript ‘0’ : (‘\u2070’, ‘\u2080’ ), ‘1’ : (‘\u00B9’, ‘\u2081’ ), ‘2’ : (‘\u00B2’, ‘\u2082’ ), ‘3’ : (‘\u00B3’, ‘\u2083’ ), ‘4’ : (‘\u2074’, ‘\u2084’ ), ‘5’ : (‘\u2075’, ‘\u2085’ ), ‘6’ : (‘\u2076’, ‘\u2086’ ), ‘7’ … Read more

What is the difference between Sink and Stream in Flutter?

Sink and Stream both are parts of the StreamController. You add a data to the StreamController using Sink which can be listened via the Stream. Example: final _user = StreamController<User>(); Sink get updateUser => _user.sink; Stream<User> get user => _user.stream; Usage: updateUser.add(yourUserObject); // This will add data to the stream. Whenever a data is added … Read more

What’s the difference between pub dependencies and dev_dependencies?

dev_dependencies are dependencies that are not available for code in the resulting application, but only for tests, examples, tools, or to add executable tools like for code generation to your project. dev_dependencies of any dependencies in your project (dependencies or dev_dependencies) are always ignored when you publish to pub.dev. See also https://dart.dev/tools/pub/pubspec

Default values of an optional parameter must be constant

Try enum MyEnum { a, b } class ClassA { final MyEnum myEnum; ClassA({this.myEnum}); } class ClassB { final ClassA classA; ClassB({this.classA}); // ClassA expression is underlined with red } no need for ‘=’ operator. It will automatically assign the value when you will pass it to the constructor. Use the ‘=’ operator only when … Read more

How to get widget’s absolute coordinates on a screen in Flutter?

You can use this extension I wrote (requires Dart 2.6): extension GlobalKeyExtension on GlobalKey { Rect? get globalPaintBounds { final renderObject = currentContext?.findRenderObject(); final translation = renderObject?.getTransformTo(null).getTranslation(); if (translation != null && renderObject?.paintBounds != null) { final offset = Offset(translation.x, translation.y); return renderObject!.paintBounds.shift(offset); } else { return null; } } } Example how to use … Read more