在 Flutter 中,我使用 flutter webview 插件来启动一个 url,如:
flutterWebviewPlugin.launch(url)
Run Code Online (Sandbox Code Playgroud)
或者
WebviewScaffold(
url: url,
appBar: new AppBar(title: Text(title), actions: [
new IconButton(
icon: const Icon(Icons.share),
onPressed: () => Share.share(url),
)
]),
withZoom: true,
withLocalStorage: true,
withJavascript: true,
);
Run Code Online (Sandbox Code Playgroud)
但是,如果打开的网页中的任何链接是应用程序链接,例如:fb://profile,我将得到 net::ERR_UNKNOWN_URL_SCHEME。
在android中,我发现解决方案是覆盖这里提到的shouldOverrideUrlLoading ,但是在flutter中我应该怎么做?
我正在将 Android Studio 用于我的 Flutter 程序,并且我想包含一个类似于Flutter Gallery 应用程序所做的 dart 文件,以便我将其用作资产而不是它作为我程序的一部分。我怎样才能做到这一点?一种解决方法是使用像“txt”这样的文件扩展名而不是“dart”,但这不是很好。
我尝试通过右键单击文件将文件标记为纯文本,但没有帮助。我可以忍受错误警告,但如果无法编译该文件(如下所示),Android Studio 不允许我重新加载程序。
我正在关注 Codelab https://developer.android.com/codelabs/kotlin-android-training-add-navigation/index.html#9,并使用以下代码来连接抽屉:
class MainActivity : AppCompatActivity() {
private lateinit var drawerLayout : DrawerLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@Suppress("UNUSED_VARIABLE")
val binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
drawerLayout = binding.drawerLayout
val navController = findNavController(R.id.myNavHostFragment)
// To support up action and also the title, the third parameter is optional and is used
// for the hamburger menu for drawer.
NavigationUI.setupActionBarWithNavController(this, navController, drawerLayout)
// show the navigation drawer
NavigationUI.setupWithNavController(binding.navView, navController)
}
override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.myNavHostFragment)
// this …Run Code Online (Sandbox Code Playgroud)