widgets/navigator.dart
/// A widget that manages a set of child widgets with a stack discipline.
/// [Navigator.of] operates on the nearest ancestor [Navigator] from the given
/// [BuildContext]. Be sure to provide a [BuildContext] below the intended
/// [Navigator].
class Navigator extends StatefulWidget {
static NavigatorState of( // 通过of()获取离context最近的Navigator对象的NavigatorState,要确保context是Navigator的子孙节点
BuildContext context, {
bool rootNavigator = false,
bool nullOk = false,
}) {
final NavigatorState navigator = rootNavigator
? context.findRootAncestorStateOfType()
: context.findAncestorStateOfType();
return navigator;
}
static Future push(BuildContext context, Route route) { // 各种push、pop api都是调用Navigator.of().XXX
return Navigator.of(context).push(route);
}
}
class NavigatorState extends State with TickerProviderStateMixin {
final GlobalKey _overlayKey = GlobalKey();
final List> _history = >[];
final Set> _poppedRoutes = >{};
/// The [FocusScopeNode] for the [FocusScope] that encloses the routes.
final FocusScopeNode focusScopeNode = FocusScopeNode(debugLabel: 'Navigator Scope');
final List _initialOverlayEntries = [];
OverlayState get overlay => _overlayKey.currentState;
initState() {
Route
Overlay是啥?
/// A [Stack] of entries that can be managed independently.
class Overlay extends StatefulWidget {
final List initialEntries;
OverlayState _overlay;
static OverlayState of(BuildContext context, { Widget debugRequiredFor }) {
final OverlayState result = context.findAncestorStateOfType();
return result;
}
}
OverlayState extends State with TickerProviderStateMixin {
final List _entries = []; // 所有OverlayEntry,通过insertAll、insert、_remove、rearrange操作增删改。
initState() {
insertAll(widget.initialEntries);
}
Widget build(BuildContext context) {
final List onstageChildren = []; // 保存可在屏幕上可见的widget
final List offstageChildren = []; // 保存在屏幕上不可见但保活的widget
bool onstage = true;
for (int i = _entries.length - 1; i >= 0; i -= 1) { // 反向遍历_entries(从新到旧)区分哪些entries是可见,如果哪个声明了不透明,底部的entries就都是不可见的了。
final OverlayEntry entry = _entries[i];
if (onstage) {
onstageChildren.add(_OverlayEntry(entry)); // OverlayEntry不是widget,把它包装成widget _OverlayEntry,会调用entry的builder创建widget。
if (entry.opaque)
onstage = false;
} else if (entry.maintainState) {
offstageChildren.add(TickerMode(enabled: false, child: _OverlayEntry(entry)));
}
}
return _Theatre( // 马上要直播了,widget是OverlayEntry,我们写的真widget在哪呢??
onstage: Stack( // visible
fit: StackFit.expand,
children: onstageChildren.reversed.toList(growable: false), // 按从底层到上层的顺序绘制widget
),
offstage: offstageChildren, // kept alive, and are built, but are not laid out or painted.
);
}
insert(OverlayEntry entry, { OverlayEntry below, OverlayEntry above }) {
entry._overlay = this; // insert时把当前OverlayState关联到OverlayEntry
setState(() { // setState !!
_entries.insert(_insertionIndex(below, above), entry);
});
}
void _remove(OverlayEntry entry) {
if (mounted) {
setState(() {
_entries.remove(entry);
});
}
}
rearrange();
}
class _OverlayEntry extends StatefulWidget {
final OverlayEntry entry;
}
class _OverlayEntryState extends State<_OverlayEntry> {
@override
Widget build(BuildContext context) {
return widget.entry.builder(context); // 调用了OverlayEntry的builder !
}
void _markNeedsBuild() {
setState(() { /* the state that changed is in the builder */ });
}
}
当某个数据库用户在数据库中插入、更新、删除一个表的数据,或者增加一个表的主键时或者表的索引时,常常会出现ora-00054:resource busy and acquire with nowait specified这样的错误。主要是因为有事务正在执行(或者事务已经被锁),所有导致执行不成功。
1.下面的语句
insert提示IGNORE_ROW_ON_DUPKEY_INDEX
转自:http://space.itpub.net/18922393/viewspace-752123
在 insert into tablea ...select * from tableb中,如果存在唯一约束,会导致整个insert操作失败。使用IGNORE_ROW_ON_DUPKEY_INDEX提示,会忽略唯一
1.记录慢查询配置
show variables where variable_name like 'slow%' ; --查看默认日志路径
查询结果:--不用的机器可能不同
slow_query_log_file=/var/lib/mysql/centos-slow.log
修改mysqld配置文件:/usr /my.cnf[一般在/etc/my.cnf,本机在/user/my.cn
@ControllerAdvice,是spring3.2提供的新注解,从名字上可以看出大体意思是控制器增强。让我们先看看@ControllerAdvice的实现:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Co
BW Element
OLAP Universe Element
Cube Dimension
Class
Charateristic
A class with dimension and detail objects (Detail objects for key and desription)
Hi