u/Droces

Learning Dart; wrapping my head around types

Hi everyone. I'm learning Dart and Flutter, and I'm trying to wrap my head around the types. I come from the web dev world, but I'm trying to approach Dart from a fresh perspective.

While trying to figure out the difference between records and the collection types, I made the follow in my notes. I tried to use clear example data to make it obvious when to use each. Is it correct or have I misunderstood anything?

--------

List

Basically an array; All values have the same type

typedef AnimalsList = List<String>;
AnimalsList animals = ['cat', 'dog'];
print(animals[0]); // 'cat'

Map

Maps keys to values; All keys and values have the same type

typedef NumeralsMap = Map<String, int>;
NumeralsMap numerals = {
  'I': 1,
  'V': 5,
};
print(numerals['I']); // 1

Set

Fixed set of values; unordered; can't get a set's items by index (position)

typedef Directions = Set<String>;
Directions directions = {'up', 'down', 'left', 'right'};
print(directions.contains('home')); // false

Record

Basically an standard object; Values and keys can be any type

typedef Dog = ({String name, int age});
Dog dog = (
  name: 'Jeff',
  age: 3,
);
print(dog.name); // 'Jeff'
reddit.com
u/Droces — 3 days ago

App to see the nearest observation as you walk

Hi everyone. A few days ago I had an idea for something that I think could be super fun - especially for kids and budding new iNatters (not sure what we're called 😄)

It's an app that does one simple thing: It shows the nearest observation to you, and updates in real-time as you walk. Basically every few seconds it scans nearby to find observations from iNat and calculates the closest, and shows it directly on your screen. The only "feature" is that you can pause it (stops scanning); super simple.

You can try it out now at https://nearestobservation.org.za

It's kind of still a prototype, as it's a web app that only I have tested so far. Please give it a try and let me know what you think!

If it's liked and valued, I'll make it into an Android and iOS app 🤓

PS. It's 100% hand-coded; no AI was used to build it (if that matters to you).

u/Droces — 6 days ago

As a follow up from my post yesterday, here are 3 more visualisations using iNat data, each telling a different story.

The first, Joro Spider (Trichonephila clavata) (thanks Luscinia68 for suggesting it). Native to East Asia, it is found throughout China, Japan (except Hokkaidō), Korea, and Taiwan, and has been spreading across North America since the 2010s. So its spreading in Eastern USA is what we might expect.

Next, the Caspian Tern (Hydroprogne caspia). Their breeding habitat includes North America, Europe, Asia, Africa, and Australasia, and their numbers are steady globally, so we'd expect to see consistent numbers of observations over time (our control group), yet there's a modest but noticable increase in their observations in iNat.

Lastly, the European Eel (Anguilla anguilla). The European eel is a critically endangered species. Numbers of eels reaching Europe is thought to have declined by around 90% (possibly even 98%) since the 1970s. In this visualisation, I've only included "wild" and "research-grade" observations, so we'd expect to see a sharp decline. But the visualisation appears to show an increase in their sightings across Europe.

So, an increase in number of observations of a species in iNat could be due to many factors like more people using the app, users observing and contributing more, greater awareness of key species and thus people looking for them more, or a number of other reasons...

Basically using observations can be super helpful in some cases, but it needs to be the start of the research process, not the end.

u/Droces — 17 days ago

Hi everyone. You might remember me sharing a gif of the worrying growth of the spotted lanternfly across Eastern USA a few months ago, made using my app On a Map and its integration with iNaturalist. Well since then, I've made lots of improvements, so I'm sharing an improved version of it here.

I've also added two new visualisations; the Cane Toad on the East coast of Australia, and the Yellow-legged (Asian) Hornet across most of Europe.

*Disclaimer: I realise there are lots of other factors affecting the number of sightings, such as just an increased number of iNat users, however the growth of these species is clear and disturbing.

u/Droces — 18 days ago
▲ 127 r/webdev

After years of making sites and web apps, I've finally discovered a solution to a really annoying problem I've had for ages 😄

In the browser console, you probably get occasional warnings and log messages from things that are outside of your control - like dependencies you need, and browser extensions. Usually I can ignore them, but sometimes some plugin or extension triggers dozens of warnings that are just cluttering up the console.

Console when opening the CSS Tricks site - I'm not affiliated with that site at all, I just like it.

You probably know that you can use the filter box at the top to filter the log to find specific messsages.

And perhaps you know that you can use a negative filter to hide certain messages.

One negative filter hiding all instances of a message containging the word \"Mixed\"

But did you know you can use regex in the filter? And did you know you could combine it with the negative filter to hide all sorts of messages? In particular, you can use it to match and hide multiple different messages!

Negative filter using regex to hide two matched messages

And this appears to work in Firefox and Chrome devtools, so I assume it'll work in other browsers too.

I'm finding this very helpful for local dev when I'm looking at the console all the time for errors and logs, so I hope you find it useful too!

Note: I wrote this post by hand; no AI was used to write it. I hope that's obvious...

reddit.com
u/Droces — 21 days ago