● Cascade notation(..) Operator : Cascades (..
) allow you to
perform a sequence of operations on the same object. The Cascades
notation(..) is similar to method chaining that saves you number
of steps and need of temporary variable.
● Version note: The ?.. syntax was introduced in 2.12.
● Spread operator(...) and null-aware spread operator (...?) : It
can be used to extend the elements of a Collection. The examples
below show the usage of the notation on List, Set, and Map.
List<int> l1 = [1, 2, 3, 4];
List<int> l1 = [6, 7, 8];
List<int> result = [0, ...l1, 5. ...l2];
print(result); => 0, 1, 2, 3, 4, 5, 6, 7, 8
(...?)
If the expression to the right of the spread operator might be
null, you can avoid exceptions by using a null-aware spread
operator (...?)
● "?."(null safety) Conditional member access : It is simply does a
null check before accessing member. If left hand side of the
operator is not null then it works simply as . and if it is null
value then the whole thing is null.
● Type test operators :
○ as Typecast (also used to specify library prefixes
○ is True if the object has the specified type
○ is! True if the object doesn’t have the specified type
● EventChannel and MethodChannel :
https://medium.com/flutter/flutter-platform-channels-ce7f540a104e
○ These channels are used to communicate between native code
(plugins or native code inside of your project) and the
Flutter framework.
○ MethodChannel - A MethodChannel is used for "communicating
with platform plugins using asynchronous method calls". This
means that you use this channel to invoke methods on the
native side and can return back a value and vise versa.
You can e.g. call a method that retrieves the device name
this way
○ EventChannel - An EventChannel is used to stream data. This
results in having a Stream on the Dart side of things and
being able to feed that stream from the native side.This is
useful if you want to send data every time a particular
event occurs, e.g. when the wifi connection of a device
changes.
Flutters build modes :
1. Debug
● In debug mode, the app is set up for debugging on the physical
device, emulator, or simulator.
● Debug mode for mobile apps mean that:
○ Assertions are enabled.
○ Service extensions are enabled.
○ Compilation is optimized for fast development and run cycles
(but not for execution speed, binary size, or deployment).
○ Debugging is enabled, and tools supporting source level
debugging (such as DevTools) can connect to the process.
● By default, "flutter run" compiles to debug mode.
● Hot reload works only in debug mode.
● The emulator and simulator execute only in debug mode.
● Android studio -> Run -> Debug main.dart
2. Release
● Use release mode for deploying the app, when you want maximum
optimization and minimal footprint size.
● For mobile, release mode (which is not supported on the simulator
or emulator), means that:
○ Assertions are disabled.
○ Debugging information is stripped out.
○ Debugging is disabled.
○ Compilation is optimized for fast startup, fast execution,
and small package sizes.
○ Service extensions are disabled.
● The command "flutter run --release" compiles to release mode.
● Android studio -> Run -> Flutter Run main.dart in Release Mode
3. Profile
● In profile mode, some debugging ability is maintained—enough to
profile your app’s performance.
● Profile mode is disabled on the emulator and simulator, because
their behavior is not representative of real performance.
● On mobile, profile mode is similar to release mode, with the
following differences:
○ Some service extensions, such as the one that enables the
performance overlay, are enabled.
○ Tracing is enabled, and tools supporting source-level
debugging (such as DevTools) can connect to the process.
● The command "flutter run --profile" compiles to profile mode.
● Android studio -> Run -> Flutter Run main.dart in Profile Mode
● Variables with all types(int, string, numeric, boolean, etc) are
initially null, because numbers—like everything else in Dart—are
objects.
● Assert : During development, use an assert statement —
assert(condition, optionalMessage); — to disrupt normal execution
if a boolean condition is false. assert(lineCount == null);
○ Production code ignores the assert() call.
○ During development, on the other hand, assert(condition)
throws an exception if condition is false.
● Late variables : Dart 2.12 added the late modifier, which has two
use cases:
○ Declaring a non-nullable variable that’s initialized after
its declaration.
○ Lazily initializing a variable.
○ Note : If you fail to initialize a late variable, a runtime
error occurs when the variable is used.
● const : Use const for variables that you want to be compile-time
constants. If the const variable is at the class level, mark it
static const.
Other types also have special roles in the Dart language:
● Object: The superclass of all Dart classes except Null.
● Future and Stream: Used in asynchrony support.
● Iterable: Used in for-in loops and in synchronous generator
functions.
● Never: Indicates that an expression can never successfully finish
evaluating. Most often used for functions that always throw an
exception.
● dynamic: Indicates that you want to disable static checking.
Usually you should use Object or Object? instead.
● void: Indicates that a value is never used. Often used as a
return type.
Functions :
● Dart is a true object-oriented language, so even functions are
objects and have a type, Function.
● This means that functions can be assigned to variables or passed
as arguments to other functions.
For functions that contain just one expression, you can use a shorthand
syntax:
bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;
The => expr syntax is a shorthand for { return expr; }. The => notation
is sometimes referred to as arrow syntax.
Parameters :
● A function can have any number of required positional parameters.
● These can be followed either by named parameters or by optional
positional parameters (but not both).
Named parameters-
● Named parameters are optional unless they’re specifically marked
as required.
● When calling a function, you can specify named parameters using
paramName: value.
○ For example: enableFlags(bold: true, hidden: false);
● When defining a function, use {param1, param2, …} to specify
named parameters:
○ void enableFlags({bool? bold, bool? hidden}) {...}
● If a parameter is optional but can’t be null, provide a default
value.
Optional positional parameters -
● Wrapping a set of function parameters in [] marks them as
optional positional parameters:
String say(String from, String msg, [String? device]) {
var result = '$from says $msg';
if (device != null) {
result = '$result with a $device';
}
return result;
}
Default parameter values -
● Your function can use = to define default values for both named
and positional parameters.
● The default values must be compile-time constants. If no default
value is provided, the default value is null.
● Here’s an example of setting default values for named parameters:
○ void enableFlags({bool bold = false, bool hidden = false})
{...}
○ enableFlags(bold: true);
The main() function :
● Every app must have a top-level main() function, which serves as
the entrypoint to the app.
● The main() function returns void and has an optional List<String>
parameter for arguments.
mixins :
● Mixins are a way of reusing a class’s code in multiple class
hierarchies.
● To use a mixin, use the with keyword followed by one or more
mixin names.
○ class Musician extends Performer with Musical {}
○ create mixin :
mixin Musical {
bool canPlayPiano = false;
void entertainMe() {
print('Playing piano');
}
}
***You can restrict a mixin’s use by using the on keyword to specify
the required superclass:***
class Musician {
// ...
}
mixin MusicalPerformer on Musician {
// ...
}
class SingerDancer extends Musician with MusicalPerformer {
// ...
}
In the preceding code, only classes that extend or implement the
Musician class can use the mixin MusicalPerformer. Because SingerDancer
extends Musician, SingerDancer can mixin MusicalPerformer.
Asynchrony support :
- Dart libraries are full of functions that return Future or Stream
objects.
- These functions are asynchronous: they return after setting up a
possibly time-consuming operation (such as I/O),
without waiting for that operation to complete.
- The async and await keywords support asynchronous programming,
letting you write asynchronous code that looks similar to synchronous
code.
1. Handling Futures
When you need the result of a completed Future, you have two options:
- Use async and await.
- Use the Future API, as described in the library tour.
To use await, code must be in an async function—a function marked as
async:
Future checkVersion() async {
var version = await lookUpVersion();
// Do something with version
}
2. Handling Streams
When you need to get values from a Stream, you have two options:
- Use async and an asynchronous for loop (await for).
- Use the Stream API, as described in the library tour.
An asynchronous for loop has the following form:
await for (varOrType identifier in expression) {
// Executes each time the stream emits a value.
}
The value of expression must have type Stream. Execution proceeds as
follows:
- Wait until the stream emits a value.
- Execute the body of the for loop, with the variable set to that
emitted value.
- Repeat 1 and 2 until the stream is closed.
To stop listening to the stream, you can use a break or return
statement, which breaks out of the for loop and unsubscribes from the
stream.
Future main() async {
// ...
await for (var request in requestServer) {
handleRequest(request);
}
// ...
}
Isolates :
https://medium.com/dartlang/dart-asynchronous-programming-isolates-and-
event-loops-bffc3e296a6a
An isolate is what all Dart code runs in.
It’s like a little space on the machine with its own, private chunk of
memory and a single thread running an event loop.
- Most computers, even on mobile platforms, have multi-core CPUs.
- To take advantage of all those cores, developers traditionally use
shared-memory threads running concurrently.
- However, shared-state concurrency is error prone and can lead to
complicated code.
- Instead of threads, all Dart code runs inside of isolates.
- Each isolate has its own memory heap, ensuring that no isolate’s
state is accessible from any other isolate.
Flutter IMP doc
https://docs.google.com/spreadsheets/d/1t9oeF9nUb7OxjIBBS4SINmnXy_OHLl2
yFQ49v-lZx5c/edit#gid=1358700511
Bloc Provider
https://pub.dev/packages/bloc
https://pub.dev/packages/flutter_bloc
https://medium.com/flutter-community/flutter-bloc-and-provider-a-shoppi
ng-cart-example-af75004e1666
flutter radio button
https://medium.com/flutter-community/working-with-radio-buttons-in-flut
ter-b50189e57b44
https://flutter-examples.com/create-multiple-radio-button-radio-group-i
n-flutter/
https://github.com/DK15/quiz-app-flutter/blob/master/lib/main.dart
https://grokonez.com/flutter/flutter-radio-button-example
https://api.flutter.dev/flutter/material/RadioListTile-class.html
https://stackoverflow.com/questions/59496880/how-to-trigger-radio-butto
n-when-text-or-another-widget-is-tapped
if you want to select radio button value on click of your textview Then
you need change groupValue of your radio button on click of your
textview
flutter - replacement of Framelayout is STACK
https://medium.com/flutter-community/flutter-for-android-developers-how
-to-design-framelayout-in-flutter-93a19fc7e7a6
ascii value table
http://support.ecisolutions.com/doc-ddms/help/reportsmenu/ascii_sort_or
der_chart.html
Flutter Gems
A Flutter package landscape guide comprising 999 neatly categorized
useful and popular packages!
https://fluttergems.dev/
flutter json serialization
https://flutter.dev/docs/development/data-and-backend/json
to generate '.g' file
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner build
How To get Flutter screen size
https://medium.com/codespace69/how-to-get-flutter-screen-size-e16d88332
ed6
qr_code_scanner 0.0.13
https://pub.dev/packages/qr_code_scanner
Searching a List of objects for a particular object in dart using
“where”
https://stackoverflow.com/questions/50892584/searching-a-list-of-object
s-for-a-particular-object-in-dart-using-where/50892754
Dart/Flutter Map, HashMap Tutorial with Examples
https://bezkoder.com/dart-map/
Useful List methods in Dart
https://medium.com/flutter-community/useful-list-methods-in-dart-6e173c
ac803d
This application cannot tree shake icons fonts. It has non-constant
instances of IconData at the following locations:
Try to build with --no-tree-shake-icons. It works for me
flutter build apk --no-tree-shake-icons
restore deleted branch from github
https://help.github.jp/enterprise/2.11/user/articles/deleting-and-resto
ring-branches-in-a-pull-request/#:~:text=Restoring%20a%20deleted%20bran
ch&text=of%20the%20repository.-,Under%20your%20repository%20name%2C%20c
lick%20Pull%20requests.,pull%20request%2C%20click%20Restore%20branch.
Generate Apk file from aab file (android app bundle)
https://stackoverflow.com/questions/53040047/generate-apk-file-from-aab
-file-android-app-bundle
For Debug apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab
--output=/MyApp/my_app.apks
For Release apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab
--output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd
https://play.google.com/store/apps/details?id=com.dotanddash.ddpattern
How do I set a monitor resolution that is not available in the Display
Settings dialog?
https://askubuntu.com/questions/330293/how-do-i-set-a-monitor-resolutio
n-that-is-not-available-in-the-display-settings/330373#330373
How to Set A Custom Screen Resolution in Ubuntu Desktop
https://ubuntuhandbook.org/index.php/2017/04/custom-screen-resolution-u
buntu-desktop/
Dart Multiple Constructors
https://stackoverflow.com/questions/49691163/dart-multiple-constructors