xxxxxxxxxx
const letters = [{letter: 'a'},{letter: 'b'},{letter: 'c'}]
const index = letters.findIndex((element, index) => {
if (element.letter === 'b') {
return true
}
})
//index is `1`
xxxxxxxxxx
// Get index of object with specific value in array
const needle = 3; // needle
const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }]; // haystack
const index = haystack.findIndex(item => item.id === needle);
xxxxxxxxxx
// Get index of object with specific value in array
const needle = 3;
const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }];
const index = haystack.findIndex(item => item.id === needle);
xxxxxxxxxx
var elementPos = array.map(function(x) {return x.id; }).indexOf(idYourAreLookingFor);
var objectFound = array[elementPos];
xxxxxxxxxx
appBar: AppBar(
title: const Text('AppBar Title'),
// Changing the text color here
titleTextStyle: TextStyle(
color: Colors.white, // Set your desired color
fontSize: 20, // Optional: set font size
),