Generate Commit Messages with Copilot
1 min read
If you're not too picky about how you write your commit messages, this can be a neat little time saver!
If you're not too picky about how you write your commit messages, this can be a neat little time saver!
If you're using multiple code generators that depend on each other, you can enforce the code generation order in your build.yaml file.
If you want to return a stream that depends on some asynchronous code, you can use async* and yield*
To avoid prompting users too early, track your desired event and only ask for a review after it is triggered N times.
How to download multiple releases from xcodereleases.com, and switch between them with the xcode-select CLI.
By implementing a NavigatorObserver, you can track page views or add navigation breadcrumbs to your error logs.
The Android debug logs can get quite noisy. To work around it, open the DevTools logging page, which will only show the Flutter logs.
Rather than calling Navigator.of(context), you can define all the push/pop methods inside a BuildContext extension and make your navigation code less verbose.
To create a stylish Text, use the ShaderMask widget with a shaderCallback that returns a LinearGradient with begin and end points, along with a list of colors.
The easiest way to add a badge to an IconButton is to use the Badge widget. Use this to show a numeric value or a custom label next to an icon.
Thanks to RawGestureDetector and SerialTapGestureRecognizer, you can implement a custom TripleTapDetector widget.
How to use the Flutter VSCode sidebar to access the DevTools and other useful functionality.
Since Flutter 3.24, a new Rebuild Stats feature is available on the DevTools performance page. Use it to spot widgets that rebuild too often.
Since Flutter 3.24, a new CarouselView widget is available. You can set the children's size with itemExtent and shrinkExtent, and use it with any widgets as children.
As of Flutter 3.24, a new "pub unpack" command is available. You can use it to download a package locally and easily explore its source code.
OverflowBar makes it easy to layout your widgets in a row unless they overflow the available horizontal space, in which case they're arranged as a column.
When you call a method that returns a Future, you have to choose between using await, unawaited, and ignore. Here's an explanation.
The humble log function has many arguments that can be used to customize the appearance of your logs. Here's how to use them.
When tracking analytics events in your code, consider using `unawaited` from `dart:async` (analytics calls should be fire & forget).
--dart-define-from-file supports both .env and json files. Here's how to use each variant.
By doing some string manipulation on the current stack trace, you can extract the current method name (useful for logging).
The hugeicons package was recently released, featuring a collection of over 4,000 stroke Flutter icons.
You can use CancelToken to stop unnecessary data fetches when users navigate away or to implement "cancel" buttons in your Flutter apps.
You can use BoxHeightStyle to change the selection height style of a TextField (useful for multi-language apps).
The widget build method can potentially be called in every frame and should not have any side effects.
If you need to show a semi-transparent image, use the opacity argument with AlwaysStoppedAnimation rather than adding a parent Opacity widget.
Forgetting to dispose controllers in your State class can lead to memory leaks, and the "dispose-fields" rule from DCM can warn you about it.
With this VSCode extension, you can remove all the unused assets, files, and dependencies in your Flutter project and decrease your app bundle size.
If you try to access a web-specific API on native platforms, your app will crash. Here's how to use conditional imports to solve this problem.
To detect the current platform, check for kIsWeb beforehand and use it together with defaultTargetPlatform, which doesn't import dart:io.
With the Universal Platform package, you can perform platform detection with a unified syntax on all platforms, including web, but there's a catch.
A collection of useful aliases to speed up your Flutter app development workflow.
How to use the Flutter CLI to save screenshots from connected iOS and Android emulators
Here's how to use typedef to define type aliases for your function and non-function types in Dart.
By adding type annotations to your collections, the Dart analyzer will warn you if you add values of the wrong type.
Const is for hardcoded, compile-time constants. Final is for read-only variables that are set just once. Var is for variables that are set more than once.
How to use the web app bootstrap process (new in Flutter 3.22) and add a CSS progress indicator before the Flutter app is ready to take over.
Here's how to use the Vector Graphics Compiler to precompile SVGs at build time for better rendering performance.
How to use the JsonCodable macro to augment your classes with fromJson and toJson methods
If you need to return an empty widget, SizedBox.shrink() is more performant than an empty Container.
By default, asserts are only enabled in Debug mode. To enable them in Release mode, run with the --enable-asserts flag.
How to send HTTP requests and view the response directly in Visual Studio Code.
If you use build_runner and your generated Dart files are added to Git, you can hide them by default in your PRs and diffs. Here's how.
Some helper widgets for creating Flutter layouts that grow horizontally up to a given width, then remain fixed at that width.
Ever wanted to filter tests so you only run the ones you need to? This can be easily done using test tags.
You can run a widget test multiple times with the variant argument. Very useful for golden image tests for different screen sizes.
Create small, reusable widgets that are easier to reason about, and banish the massive build method from existence!
In Flutter you can use DecoratedBox to set a lot of decoration/styling options to your widgets. Here's how.
The faker package lets you generate addresses, names, food, dates, sports... you name it! Here's how to use it.
A useful tip to write more performant code when using SizedBox as a gap between widgets inside a Row or Column layout.
If you have many AsyncNotifier subclasses, using try/catch can be tedious. With AsyncValue.guard you get the same result with less boilerplate.
How to style an ElevatedButton in Flutter, including reusing the same style across all buttons with ThemeData.
How to add a GitHub Actions workflow to automatically run tests when you push your code.
How to easily add fixed spacing inside Flex widgets such as Columns and Rows or scrolling views.
Since Flutter 3.7, BuildContext has a mounted property that we can check after an asynchronous gap. Here's how to use it.
An overview of what Dart Fix can do for you, along with some useful VSCode productivity tips and settings for Flutter app development.
Flutter apps built for macOS need a client network entitlement in order to make network requests. Here's how to configure it.
DartPad makes it easy to share your Dart & Flutter samples using GitHub gists, and you can even embed them on your website. Here's how.
When a test waits for a stream value that is never emitted, it will timeout after 30 seconds (by default). Here's how to make it fail fast with a custom timeout.
Since Dart 2.17, you can initialize parameters of the super class with a new shorthand syntax. Here's how.
Since Dart 2.17, we can add members and additional methods when declaring an enum. Here's how.
When writing tests for functions that throw, we should not invoke them directly, but rather pass them as arguments using a tear-off.
Ever needed to update a value if a given key already exists, or set it if it doesn't? Here's how to use the Map.update() method to solve this.
How to use the precompiled Firestore iOS SDKs to speed-up Xcode builds on your Flutter apps.
Many Material widgets such as InkWell, ElevatedButton, and ListTile show a splash effect when selected. Here's how to disable this.
Two effective techniques for reducing code generation times for Flutter apps that use build_runner.
Easy ways to improve your Dart & Flutter code. Published weekly.
Easy ways to improve your Dart & Flutter code. Published weekly.
Easy ways to improve your Dart & Flutter code. Published weekly.
Easy ways to improve your Dart & Flutter code. Published weekly.
Easy ways to improve your Dart & Flutter code. Published weekly.
Easy ways to improve your Dart & Flutter code. Published weekly.
A useful tip to hide your Firebase config from git in your Flutter web projects.
FocusScopeNode provides a simpler way of move the focus between text fields in your Flutter forms.
How to remove some noise in your Dart code by using underscores for unused function arguments.
How to make your ListViews feel native on iOS by adding top and bottom separators.