function invokeServiceWorkerUpdateFlow() {
// you have a better UI here, reloading is not a great user experince here.
const confirmed = confirm('New version of the app is available. Refresh now');
if (confirmed) {
window.location.reload();
}
}
async function handleServiceWorker() {
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const TabBarDemo()); | |
} | |
class TabBarDemo extends StatefulWidget { | |
const TabBarDemo(); | |
@override |
<script> | |
document.querySelector('#username').addEventListener('input', console.log); | |
document.querySelector('#password').addEventListener('input', console.log); | |
</script> |
// myTextWIdget my_text_widget.dart | |
import 'package:flutter/material.dart'; | |
class MyTextWidget extends StatelessWidget { | |
MyTextWidget({ | |
this.title, | |
this.fontWeight, | |
this.fontSize, | |
this.color, | |
}); |
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
abstract class PhotosRepository { | |
Future<List<Photo>> getPhotosList(); | |
} | |
class Photo { | |
Photo({ |
RepaintBoundary
artificially pretends that the child needs its own composited layer which means the effects in sub-tree are then contained. This is a great tip to improve performance in Flutter boosting to 60 FPS.
check in action: https://codepen.io/mhadaily/pen/ZEWWEKp
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
reflect
Returns an [InstanceMirror] reflecting reflectee. If
reflecteeis a function or an instance of a class that has a
callmethod, the returned instance mirror will be a
ClosureMirror`.Note that since one cannot obtain an object from another isolate, this function can only be used to obtain mirrors on objects of the current isolate.
A MirrorSystem
is the main interface used to reflect on a set of associated libraries. At runtime each running isolate has a distinct MirrorSystem
. It is also possible to have a MirrorSystem
which represents a set of libraries which are not running -- perhaps at compile-time. In this case, all available reflective functionality would be supported, but runtime functionality (such as invoking a function or inspecting the contents of a variable) would fail dynamically.
simpleName
getter is for Dart language entity. The simple name is in most cases the identifier name of the entity, such as 'myMethod' for a method, void myMethod() {...}
or 'mylibrary' for a
A stack implements LIFO
(last-in first-out) ordering.
It uses the operations:
push(item)
: push an item to the top of the stackpop()
: Remove the top item in the stackpeek()
: Return the top of the stackisEmpty()
: Return true if and on if the stack is empty
There are several places that we can use Stack but it may appear in recursive operations the most. For example, when part of the recursive function fails and you want to roll back everything, Stack sounds like a good plan for that.
A queue implements FIFO
(first-in first-out) ordering.
It uses the operations:
add(item)
: Add an item to the end of the listremove()
: Remove the first item in the listpeek()
: Return the top of the queueisEmpty()
: Return true if and on if the queue is empty
There are several places that we can use Queue but it may appear in Cache or Breadth-first search the most.