[英]How to prevent widgets from being shown in notification bar in flutter
I have a code here for a simple webview. It simply displays a webpage.我这里有一个简单的代码 webview。它只显示一个网页。 However, the top part of the webpage is shown stacked below the notification bar(As in some of the buttons on the top part of the page).
但是,网页的顶部显示为堆叠在通知栏下方(如页面顶部的某些按钮)。 How can I prevent this?
我怎样才能防止这种情况发生? I know I can hide the notification bar/icons, but I want to show the contents of the webview widgets below the notification bar without hiding it.
我知道我可以隐藏通知栏/图标,但我想在通知栏下方显示 webview 小部件的内容而不隐藏它。 I also don't want to use an app bar.
我也不想使用应用程序栏。 Kindly help me out
请帮帮我
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
late WebViewController controller;
@override
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: WebView(
initialUrl: 'https://flutter.dev',
javascriptMode: JavascriptMode.unrestricted,
)),
debugShowCheckedModeBanner: false,
);
}
}
Just wrap your webviw with SafeArea
用 SafeArea 包裹你的
SafeArea
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
WebViewController controller;
@override
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: WebView(
initialUrl: 'https://flutter.dev',
javascriptMode: JavascriptMode.unrestricted,
),
)),
debugShowCheckedModeBanner: false,
);
}
}
output: output:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.