Comments (3)
试试
return context.dependOnInheritedWidgetOfExactType< AppConfig >();
from 34_multi_env.
static AppConfig? of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType< AppConfig >();
}
必须加个?才行,但是这里加了?,所有调用的地方都要加!。好像是什么Nullable相关的。
话说现在还需要用这种方法,做多环境切换吗?是不是新版的有别的方法了?
from 34_multi_env.
函数声明既然是有可能返回null,代码里自然要做好处理了。?和!是应对可能出现的null的语法糖
做多环境切换,方法比较多,本质上就是把多环境的配置预置在代码或配置文件里,通过:
1.在编译器配置不同的代码入口,在启动时走不同的环境
2.通过断言或编译常数识别出当前的编译模式,走不同的分支,做编译期或运行期的静态或动态切换
3.二者相结合
这些方法对于大部分的语言都是通用的,和新版旧版没关哈
from 34_multi_env.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 34_multi_env.