First Lesson of Reso Coder Free Course
Joining Lists without Spread Operator
List<int> joinCollectionsWithoutSpread() {
final collection = [1, 2, 3];
final otherCollection = [4, 5, 6];
collection.addAll(otherCollection);
return collection;
}
Joining Lists with Spread Operator
List<int> joinCollectionsWithSpread() {
final collection = [1, 2, 3];
final otherCollection = [4, 5, 6];
return [...collection, ...otherCollection];
}
Spread can be used like this...
ListView(
children: <Widget>[
Text('Fake email input'),
Text('Fake password input'),
if (showLoginUI) ...[
RaisedButton(
child: Text('Login'),
onPressed: () {},
),
FlatButton(
child: Text('Forgotten Password'),
onPressed: () {},
),
],
if (!showLoginUI)
RaisedButton(
child: Text('Register'),
onPressed: () {},
),
],
);
Without Using Cascade...
List<int> withoutCascade() {
final list = [5, 1, 3, 2, 4];
list.sort();
list.removeLast();
return list;
}
With Using Cascade..
List<int> withCascade() {
return [5, 1, 3, 2, 4]
..sort()
..removeLast();
}
import 'package:flutter/material.dart';
void withoutCoalescing() {
String myValue;
String fallbackValue = 'fallback';
String result;
if (myValue == null)
result = fallbackValue;
else
result = myValue;
final resultTernary = myValue == null ? fallbackValue : myValue;
print(result);
print(resultTernary);
}
void withCoalescing() {
String myValue;
String fallbackValue = 'fallback';
final result = myValue ?? fallbackValue;
print(result);
}
void assignment() {
String uninitializedValue;
String initializedValue = 'something';
uninitializedValue ??= 'new value';
initializedValue ??= 'new value';
print(uninitializedValue);
print(initializedValue);
}
void access() {
String uninitializedValue;
String initializedValue = 'something';
print(uninitializedValue?.toUpperCase());
print(initializedValue?.toUpperCase());
}
void spread() {
List<int> collection;
final otherCollection = [4, 5, 6];
final result = [...?collection, ...?otherCollection];
print(result);
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
// withoutCoalescing();
// withCoalescing();
// assignment();
// access();
spread();
return Container();
}
}
-
Instead of using nested List Views, pre-process the lists into one list and show that list.
https://timm.preetz.name/articles/nested-listviews-in-flutter
-
android match_parent and wrap_content in flutter
-
Multiple Theme in Flutter(Integrated in this repository)
-
Dark and Light Theme in Flutter(Now Integrated)
-
Get Widget A ready made widgets for Flutter
-You know what? I will try to implement something with agora.