As Dart developers, we’re no strangers to asynchronous programming and the power of Future
s. In the past, when we needed to wait for multiple futures concurrently, we relied on the Future.wait([])
method, which returned a List<T>
. However, this approach had a significant drawback: we had to manually cast the results to their desired types, which could lead to verbose and error-prone code.
final results = await Future.wait([
Future.value("andrew"),
Future.value(1984),
]);
expect((results[0] as String).toUpperCase(), "ANDREW");
expect((results[1] as int).isNegative, false);
Fortunately, there’s a more elegant solution that leverages the power of extensions and async/await syntax: the zipWith
extension method.
zipWith
The zipWith
extension method allows you to combine the results of two futures into a typed tuple, eliminating the need for manual casting. Here's how it works:
final (name, year) = await Future.value("andrew")
.zipWith(Future.value(1984));
expect(name.toUpperCase(), "ANDREW");
expect(year.isNegative, false);
In this example, we’re combining the results of two futures: one that resolves to the string “andrew” and another that resolves to the integer 1984. The zipWith
method returns a tuple (T, T2)
where T
is the type of the first future, and T2
is the type of the second future.
But wait, there’s more! You can even chain multiple zipWith
calls to combine the results of three or more futures:
final ((name, year), married) = await Future.value("andrew")
.zipWith(Future.value(1984))
.zipWith(Future.value(false));
expect(married, false);
In this example, we’re combining three futures, resulting in a nested tuple ((T, T2), T3)
.
So, how does zipWith
work its magic? Here's the implementation:
extension FutureZipX<T> on Future<T> {
Future<(T, T2)> zipWith<T2>(Future<T2> future2) async {
late T result1;
late T2 result2;
await Future.wait([
then((it) => result1 = it),
future2.then((it) => result2 = it)
]);
return (result1, result2);
}
}
By embracing the power of zipWith
, you can write cleaner, more expressive code when working with multiple asynchronous operations. No more manual casting or fiddling with List<dynamic>
– just concise, type-safe tuples that make your code easier to read and maintain.
So, the next time you find yourself juggling multiple futures, give zipWith
a try and experience the joy of streamlined asynchronous programming in Dart.
Flatten nested tuples: https://gist.github.com/yongjhih/89a199ec14127f92a001d2e15e8a32ac
Now that the dust has settled on the news of layoffs at Google, let’s take a quick look at what this means for Flutter.
The news of layoffs in the Flutter team had no detail — was 1% of the team effected or 50%? It was not clear.
Without concrete information, the rumour mill went into overdrive (perhaps not without good reason…more on that later).
Eventually, Michael Thompson from Google clarified the situation. Basically the changes to Flutter effected some of the DevOps roles, but otherwise the team size stays the same.
TL;DR — the news headlines created a lot of unnecessary drama but the reality is actually that nothing substantive is changing.
What this week has showed (again), is that Google has created a lot of mistrust in it’s commitment to products and projects.
Google is really damaging it’s brand with all the high profile projects being killed which is exacerbated by the volume of small ones — see https://killedbygoogle.com/.
Whilst the Flutter technology is strong, the community vibrant and the real world backing plentiful, Google is making is much harder for companies to invest in building Flutter-based software.
Despite Google’s efforts to scare the Flutter community, our view is that Flutter has crossed a threshold that makes it too big to fail.
Let’s just look at who is betting on Flutter:
Toyota is using Flutter to build its next gen Infotainment Systems that will be in thousands of cars across the globe. Read more.
Ubuntu 23.04 shipped with a new installer tool written in Flutter. Canonical (the company behind Ubuntu) has indicated that it would use Flutter as the technology for future desktop app development. Read more.
Google Earth for mobile and web was rewritten in Flutter, another signal that Google’s engineers are betting on Flutter. Read more.
Google Pay on iOS and Android was implemented using Flutter. Another sign of Google’s commitment. Read more.
Google Classroom rebuilt it’s mobile apps using Flutter having been inspired by what the Google Pay team were able to achieve. Read more.
Alibaba built Xianyu (a 50+ million user marketplace) using Flutter
eBay built the eBay Motors mobile app using Flutter. Read more.
The investments in Flutter from inside Google and from the community are a good indicator that Flutter has survived it’s infancy.
Whilst we believe that Flutter is here to stay, there are questions about the rate of adoption.
On the Flutter showcase page, you will see the projects from the biggest brands are from 2021. Canonical’s bold claims that they are “making Flutter the default choice for future Canonical mobile and desktop apps” have not yet translated into reality.
The Flutter leadership team (e.g. Eric Seidel, Tim Sneath) that achieved initial success have moved onto other companies or projects.
Google is great at getting projects into the world and creating initial adoption. However, it has proven itself less able to stick it out during the long hard road to widespread adoption.
Google needs to double-down on Flutter through this adoption phase — as it did with Angular, Android, Golang and many other great contributions.
Will it do so? That’s the question looms large in light of the latest round of layoffs.
If the Flutter team is allowed to continue on it’s current trajectory, there are signs that they will continue to make good progress. For example see this Reddit post: Headspace (65 million users) is migrating to Flutter.
Our general expectation is for the mobile development landscape to shift towards a more efficient model for building across multiple devices. Flutter will be an importat part of that story on mobile.
However, we see great opportunity for Flutter to also flourish outside the mobile world.
Flutter could be key to widespread adoption of WebAssembly, a way to run compiled applications in the browser — see Figma’s WebAssembly story. The Flutter team already have Wasm support in Beta.
At Snapp, we are also betting on Flutter as a modern replacement to Qt for UI development for embedded software. The Snapp Embedded project from our sister company, Snapp-X is building the tooling to make this possible and we are already working with one of the world’s largest manufacturers of white goods (freezers, ovens, washing machines) to build device UIs using Flutter.
For more widespread adoption, Flutter will need to show how it is truly cross platform with massive code reuse across mobile and web. This is one of the biggest advantages over ReactNative — the incumbent for non-native mobile development.
Gujarati 4.4x fewer tokens (from 145 to 33)
હેલો, મારું નામ જીપીટી-4o છે. હું એક નવા પ્રકારનું ભાષા મોડલ છું. તમને મળીને સારું લાગ્યું!
Telugu 3.5x fewer tokens (from 159 to 45)
నమస్కారము, నా పేరు జీపీటీ-4o. నేను ఒక్క కొత్త రకమైన భాషా మోడల్ ని. మిమ్మల్ని కలిసినందుకు సంతోషం!
Tamil 3.3x fewer tokens (from 116 to 35)
வணக்கம், என் பெயர் ஜிபிடி-4o. நான் ஒரு புதிய வகை மொழி மாடல். உங்களை சந்தித்ததில் மகிழ்ச்சி!
Marathi 2.9x fewer tokens (from 96 to 33)
नमस्कार, माझे नाव जीपीटी-4o आहे| मी एक नवीन प्रकारची भाषा मॉडेल आहे| तुम्हाला भेटून आनंद झाला!
Hindi 2.9x fewer tokens (from 90 to 31)
नमस्ते, मेरा नाम जीपीटी-4o है। मैं एक नए प्रकार का भाषा मॉडल हूँ। आपसे मिलकर अच्छा लगा!
Urdu 2.5x fewer tokens (from 82 to 33)
ہیلو، میرا نام جی پی ٹی-4o ہے۔ میں ایک نئے قسم کا زبان ماڈل ہوں، آپ سے مل کر اچھا لگا!
Arabic 2.0x fewer tokens (from 53 to 26)
مرحبًا، اسمي جي بي تي-4o. أنا نوع جديد من نموذج اللغة، سررت بلقائك!
Persian 1.9x fewer tokens (from 61 to 32)
سلام، اسم من جی پی تی-۴او است. من یک نوع جدیدی از مدل زبانی هستم، از ملاقات شما خوشبختم!
Russian 1.7x fewer tokens (from 39 to 23)
Привет, меня зовут GPT-4o. Я — новая языковая модель, приятно познакомиться!
Korean 1.7x fewer tokens (from 45 to 27)
안녕하세요, 제 이름은 GPT-4o입니다. 저는 새로운 유형의 언어 모델입니다, 만나서 반갑습니다!
Vietnamese 1.5x fewer tokens (from 46 to 30)
Xin chào, tên tôi là GPT-4o. Tôi là một loại mô hình ngôn ngữ mới, rất vui được gặp bạn!
Chinese 1.4x fewer tokens (from 34 to 24)
你好,我的名字是GPT-4o。我是一种新型的语言模型,很高兴见到你!
Japanese 1.4x fewer tokens (from 37 to 26)
こんにちわ、私の名前はGPT−4oです。私は新しいタイプの言語モデルです、初めまして
Turkish 1.3x fewer tokens (from 39 to 30)
Merhaba, benim adım GPT-4o. Ben yeni bir dil modeli türüyüm, tanıştığımıza memnun oldum!
Italian 1.2x fewer tokens (from 34 to 28)
Ciao, mi chiamo GPT-4o. Sono un nuovo tipo di modello linguistico, è un piacere conoscerti!
German 1.2x fewer tokens (from 34 to 29)
Hallo, mein Name is GPT-4o. Ich bin ein neues KI-Sprachmodell. Es ist schön, dich kennenzulernen.
Spanish 1.1x fewer tokens (from 29 to 26)
Hola, me llamo GPT-4o. Soy un nuevo tipo de modelo de lenguaje, ¡es un placer conocerte!
Portuguese 1.1x fewer tokens (from 30 to 27)
Olá, meu nome é GPT-4o. Sou um novo tipo de modelo de linguagem, é um prazer conhecê-lo!
French 1.1x fewer tokens (from 31 to 28)
Bonjour, je m'appelle GPT-4o. Je suis un nouveau type de modèle de langage, c'est un plaisir de vous rencontrer!
English 1.1x fewer tokens (from 27 to 24)
Hello, my name is GPT-4o. I'm a new type of language model, it's nice to meet you!
It’s a day that ends in Y, so naturally, we’re dealing with yet another Google Pixel hardware leak. This time, the Pixel 9, 9 Pro, and 9 Pro XL can be seen side by side in new images from Rozetked — a full five months before Google’s typical October release timeframe.
I have many questions about how and why these units are out in the world so early, but here we are. And I know a lot of you are no doubt eyeing that regular 9 Pro, which will finally put Google’s very best camera chops into a normal-sized phone. Meanwhile, the 9 Pro XL looks a fair bit taller than Apple’s iPhone 15 Pro Max.
l’m a bit curious as to whether Google will still call this a “camera bar”...