2
  1. 我无法从 web 视图中删除标题。有没有办法删除 webview 网站的标题并将应用程序标题应用到 web 视图,这样网站标题被删除,我们的应用程序栏作为标题显示在应用程序上。

  2. 我想在底部导航栏下的 svg 图标上添加黄色下划线,我无法添加,请帮帮我。 我的应用程序的主页

import 'dart:async';
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
/* import 'package:titled_navigation_bar/titled_navigation_bar.dart' ;*/
import 'package:flutter_svg/flutter_svg.dart';

/* import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; */
import 'package:webview_flutter/webview_flutter.dart';

/* import 'package:md2_tab_indicator/md2_tab_indicator.dart'; */

/*import 'package:flutter_inappwebview/flutter_inappwebview.dart'; */
main() {
  runApp(MyApp());
}

// ignore: use_key_in_widget_constructors
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: SplashScreen()); // define it once at root level.
  }
}

// ignore: use_key_in_widget_constructors
class SplashScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SplashScreenState();
  }
}

class SplashScreenState extends State<SplashScreen> {
  @override
  void initState() {
    super.initState();

    if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();

    Timer(
        // ignore: prefer_const_constructors
        Duration(seconds: 1),
        () => Navigator.pushReplacement(
            context, MaterialPageRoute(builder: (context) => HomeScreen())));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      body: Center(child: Image.asset('assets/splash.jpeg')),
    );
  }
}

// ignore: use_key_in_widget_constructors
class HomeScreen extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<HomeScreen> {
  final Completer<WebViewController> _controller =
      Completer<WebViewController>();

  num _stackToView = 1;
  int _selectedTabIndex = 0;
  // ignore: prefer_final_fields
  List _pages = [
    // ignore: prefer_const_constructors
    Text("Home"),
    // ignore: prefer_const_constructors
    Text("Wishlist"),
    // ignore: prefer_const_constructors
    Text("Search"),
    // ignore: prefer_const_constructors
    Text("Bookings"),
    // ignore: prefer_const_constructors
    Text("Menu"),

    Text("call"),
  ];

  _changeIndex(int index) {
    setState(() {
      _selectedTabIndex = index;
    });
  }

  void _handleLoad(String value) {
    setState(() {
      _stackToView = 0;
    });
  }

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    final colorScheme = Theme.of(context).colorScheme;
    return Scaffold(
      appBar: AppBar(
          /*  automaticallyImplyLeading: false, */
          leading: Padding(
            padding: EdgeInsets.all(10.0),
            child: SvgPicture.asset("assets/svg/VW-logo.svg"),

            /* leadingWidth: 35, */
          ),
          actions: [
            IconButton(
              icon: SvgPicture.asset("assets/svg/new.svg", color: Colors.black),
              onPressed: () {},
            ),
            IconButton(
              icon: SvgPicture.asset("assets/svg/Page-1.svg"),
              onPressed: () {
                _launchURL();
              },
            ),
          ],
          backgroundColor: Colors.white),
      body:
          /* const WebView(
        initialUrl: 'https://www.google.com/',
        javascriptMode: JavascriptMode.unrestricted,
      ), */

          /* Center(child: _pages[_selectedTabIndex]), */
          IndexedStack(
        index: _selectedTabIndex,
        children: [
          Column(
            children: <Widget>[
              Expanded(
                  child: WebView(
                initialUrl: "https://www.veenaworld.com/",
                javascriptMode: JavascriptMode.unrestricted,
                onPageFinished: _handleLoad,
                onWebViewCreated: (WebViewController webViewController) {
                  _controller.complete(webViewController);
                },
              )),
            ],
          ),
          Container(
            child: Center(child: _pages[_selectedTabIndex]),
          ),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _selectedTabIndex,
        onTap: _changeIndex,
        type: BottomNavigationBarType.fixed,
        /*    backgroundColor: Colors.blue.shade900, */
        selectedLabelStyle: textTheme.caption,
        unselectedLabelStyle: textTheme.caption,
        /*  Container(   
       decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(width: 1.0, color: Colors.black),
          ),
        ), 
        ), */
        selectedItemColor: Colors.black,
        unselectedItemColor: Colors.black.withOpacity(.60),
        items: [
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/svg/home-alt2.svg",
                  color: Colors.black),
              title: Text("Home")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/svg/favourite.svg",
                  color: Colors.black),
              title: Text("Wishlist")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/svg/search.svg",
                  color: Colors.black),
              title: Text("Search")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/svg/bag.svg", color: Colors.black),
              title: Text("Bookings")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/svg/hamburger.svg",
                  color: Colors.black),
              title: Text("Menu"))
        ],
      ),
    );
  }
}

_launchURL() async {
  const url = 'https://www.google.com/';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}


4

1 回答 1

2

对于操纵 WebView,我认为没有办法做到这一点,也许您可​​以使用像堆栈这样的技巧来隐藏 WebView 应用栏,如下所示:

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    final colorScheme = Theme.of(context).colorScheme;
    return Scaffold(
      // appBar: AppBar(
      //     /*  automaticallyImplyLeading: false, */
      //     leading: Padding(
      //       padding: EdgeInsets.all(10.0),
      //       child: SvgPicture.asset("assets/images/Helmet.svg"),
      //
      //       /* leadingWidth: 35, */
      //     ),
      //     actions: [
      //       IconButton(
      //         icon: SvgPicture.asset("assets/images/Helmet.svg",
      //             color: Colors.black),
      //         onPressed: () {},
      //       ),
      //     ],
      //     backgroundColor: Colors.white),
      body: Stack(
        children: [
          IndexedStack(
            index: _selectedTabIndex,
            children: [
              Column(
                children: <Widget>[
                  Expanded(
                      child: WebView(
                    initialUrl: "https://www.veenaworld.com/",
                    javascriptMode: JavascriptMode.unrestricted,
                    onPageFinished: _handleLoad,
                    onWebViewCreated: (WebViewController webViewController) {
                      _controller.complete(webViewController);
                    },
                  )),
                ],
              ),
              Container(
                child: Center(child: _pages[_selectedTabIndex]),
              ),
            ],
          ),
          AppBar(
            /*  automaticallyImplyLeading: false, */
            leading: Padding(
              padding: EdgeInsets.all(10.0),
              child: SvgPicture.asset("assets/images/Helmet.svg"),

              /* leadingWidth: 35, */
            ),
            actions: [
              IconButton(
                icon: SvgPicture.asset("assets/images/Helmet.svg",
                    color: Colors.black),
                onPressed: () {},
              ),
            ],
            backgroundColor: Colors.white,
          ),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _selectedTabIndex,
        onTap: _changeIndex,
        type: BottomNavigationBarType.fixed,
        /*    backgroundColor: Colors.blue.shade900, */
        selectedLabelStyle: textTheme.caption,
        unselectedLabelStyle: textTheme.caption,
        /*  Container(
       decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(width: 1.0, color: Colors.black),
          ),
        ),
        ), */
        selectedItemColor: Colors.black,
        unselectedItemColor: Colors.black.withOpacity(.60),
        items: [
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/images/Helmet.svg",
                  color: Colors.black),
              title: Text("Home")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/images/Helmet.svg",
                  color: Colors.black),
              title: Text("Wishlist")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/images/Helmet.svg",
                  color: Colors.black),
              title: Text("Search")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/images/Helmet.svg",
                  color: Colors.black),
              title: Text("Bookings")),
          BottomNavigationBarItem(
              icon: SvgPicture.asset("assets/images/Helmet.svg",
                  color: Colors.black),
              title: Text("Menu"))
        ],
      ),
    );
  }
于 2021-06-16T08:59:35.470 回答