Skip to content

Instantly share code, notes, and snippets.

View mraleph's full-sized avatar
🐌

Slava Egorov mraleph

🐌
View GitHub Profile

This step by step guide uses issue RegEx: add a way to get the positions of groups #42307 as a concrete example.

Step 0: Ask the team

Ask Dart team before jumping into the implementation. The best place to ask is on the issue tracker, you can also try hackers-dart channel on Flutter Discord or one of the channels on Dart Community discord - but most SDK developers are not on either of them.

Why ask the team?

  • They might give you suggestions for the design and implementation
  • They might warn you about potential challenges
  • They might have tried implementing such feature before, faced unexpected complications and had to back out.
@mraleph
mraleph / main.dart
Created May 30, 2023 09:56
vagrant-flurry-5605
class X {
final int Function() foo;
const X({this.foo = _defaultFoo});
static int _defaultFoo() => 0;
}
void main() {
print(const X().foo());
// Based on Martin Kustermann's version and adding support for
// finalization of memory mapped views.
 
import 'dart:ffi';
import 'dart:io';
import 'dart:typed_data';
import 'dart:math' as math;
 
import 'package:ffi/ffi.dart';
 
void main() {
final count = 1000000;
final names = ['good', 'bad', 'whatever'];
final tests = [_test1, _test2, _test3];
final sw = Stopwatch();
var repeat = 10;
sw.start();
while (repeat-- > 0) {
for (var i = 0; i < tests.length; i++) {
final name = names[i];
This file has been truncated, but you can view the full file.
+------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| Library | Method | Diff (Bytes) |
+------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| package:gallery/codeviewer/code_segments.dart | CodeSegments.transformationsDemo
This file has been truncated, but you can view the full file.
+------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| Library | Method | Diff (Bytes) |
+------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| package:gallery/codeviewer/code_segments.dart | CodeSegments.transformationsDemo
diff --git a/lib/recase.dart b/lib/recase.dart
index da14cec..42a1251 100644
--- a/lib/recase.dart
+++ b/lib/recase.dart
@@ -1,44 +1,94 @@
+import 'dart:typed_data';
+
/// An instance of text to be re-cased.
class ReCase {
- final RegExp _upperAlphaRegex = new RegExp(r'[A-Z]');

First create a hello.dart file with the following content.

void main(List<String> args) {
  print('Hello, World!');
}

Next we precompile this file using PRODUCT AOT compiler (equivalent of running flutter build aot --release).

// Copyright (c) 2020, the Dart project authors.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
void sayHello() => print('Hello, World!');