Disable zooming field from webview on ios

383 views
Skip to first unread message

Fairouz Jaâfar

unread,
Mar 1, 2022, 6:50:32 AM3/1/22
to Flutter Development (flutter-dev)
Hello,

I'm a new developper flutter application, i used the plugin webview_pro to show my web forms in android it's work fine but in ios i have input text with zoom i want to disable this behavior .this is my source code and   a screen shot :

class CreateOutmail extends StatefulWidget {
  @override
  _CreateOutmailState createState() => _CreateOutmailState();
}

class _CreateOutmailState extends State<CreateOutmail> {
  final Completer<WebViewController> _controller = Completer<WebViewController>();
  var urlapp = globals.protocole + globals.nomHote + globals.database;
  int _selectedIndex = 5;
  String unid= globals.unid;


  late StreamSubscription<DataConnectionStatus> listener;
  Icon _searchIcon = new Icon(Icons.search);
  late WebViewController webViewController1;
  Widget _appBarTitle = new Text('Mail Manager');
  List<String> selectedType = [];
  late SharedPreferences sharedPreferences;
  late String SELECTEDURL="";
 final cookieManager = WebviewCookieManager()  ;

  final List<String> _listViewData = ["Mes Courriers","Courrier Arrivée", "Courrier Départ","Courrier Interne", "Tous","Nouveau Courrier Départ"];
  @override
  void initState() {
    super.initState();
 ;
    if(unid !=""){
      this.SELECTEDURL = urlapp + "outmail.xsp?documentId="+unid+"&action=editDocument";
    }
else {
    this.SELECTEDURL = urlapp + "outmailcreate.xsp";
    }
    if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
      cookieManager.setCookies([
      Cookie('DomAuthSessId', globals.DomAuthSessId)
        ..domain = globals.nomHote

      ]);
  }

  _onSelected(int index) {
    setState(() {
      _selectedIndex=index;
    });

    switch (_selectedIndex) {
      case 0:
        {
          Navigator.push( context, MaterialPageRoute(builder: (context) => MesCourriers()), );
        }
        break;
      case 1:
        {
          Navigator.push( context, MaterialPageRoute(builder: (context) => inmail()), );
        }
        break;
      case 2:
        {
          Navigator.push(context, MaterialPageRoute(builder: (context) => outmail()), );
        }
        break;
      case 3:
        {
          Navigator.push( context, MaterialPageRoute(builder: (context) => internalmail()), );
        }
        break;
      case 4:
        {
          Navigator.push( context, MaterialPageRoute(builder: (context) => ALLMail()), );
        }
        break;

      case 5:
        {
          Navigator.push( context,new MaterialPageRoute(builder: (context1) => CreateOutmail()), );
        }
        break;

    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(

      appBar: AppBar(
        title: _appBarTitle,
          leading: Builder(builder: (BuildContext context) {
          return IconButton(
            icon: Icon(Icons.menu),
            onPressed: () {
              Scaffold.of(context).openDrawer();
            },
          );
        }),
        actions: <Widget>[
          Builder(
            builder: (context) {
              return IconButton(
                  icon: Icon(Icons.settings),
                  onPressed: () {
                    Scaffold.of(context).openEndDrawer();
                  });
            },
          )
        ],
      ),
      drawer: Drawer(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Container(
                    height: 110,
                    child: DrawerHeader(
                      decoration: BoxDecoration(color: Colors.transparent),
                      child: GestureDetector(
                        child: ListView(
                          children: <Widget>[
                            new Image(
                              width: 150.0,
                              height: 50.0,
                              image: AssetImage('assets/images/mmicon.gif'),
                            ),
                          ],
                        ),
                      ),
                    )),
                Expanded(
                  child: ListView.builder(
                    itemCount:_listViewData.length,
                    itemBuilder: (context, index) => Container(
                      color: _selectedIndex != null && _selectedIndex == index
                          ? Colors.lightBlue
                          : Colors.white,
                      child: ListTile(
                          leading: getIcon(_listViewData[index]),
                          title: Text(_listViewData[index], style: TextStyle(fontSize: 16,color: Colors.black87),
                          ),
                          onTap: () {
                            _onSelected(index);
                            //Navigator.of(context).pop(true);
                          }

                      ),
                    ),
                  ),
                )
              ])),
      endDrawer: Drawer(
        child: Container(
          height: 100.0,
          color: Colors.white,
          child: Center(
              child: ListView(
                children: ListTile.divideTiles(
                  // ListTile.divideTiles
                    context: context,
                    tiles: [
                      ListTile(
                        leading: Icon(Icons.confirmation_number_outlined),
                        title: Text('Version :'+globals.version),
                        onTap: () => {logout()},
                      ),
                      ListTile(
                        leading: Icon(Icons.supervised_user_circle),
                        title: Text('Utilisateur :' + globals.user),
                      ),
                      /*ListTile(
                        leading: Icon(Icons.password),
                        title: Text('Mot de passe :'+globals.password),
                      ),*/
                      ListTile(
                        leading: Icon(Icons.exit_to_app),
                        title: Text('Déconnexion'),
                        onTap: () => {logout()},
                      ),
                    ]).toList(),
              )),
        ),
      ),

      body: Builder(builder: (BuildContext context) {
        return WebView(

          initialUrl:this.SELECTEDURL,

          javascriptMode: JavascriptMode.unrestricted,

          onWebViewCreated: (WebViewController webViewController) async {

            _controller.complete(webViewController);

          },
          onProgress: (int progress) {
          //  print("WebView is loading (progress : $progress%)");
          },
          javascriptChannels: <JavascriptChannel>{
            _toasterJavascriptChannel(context),
          },
          navigationDelegate: (NavigationRequest request) {


            return NavigationDecision.navigate;
          },
          onPageStarted: (String url) {
            print('Page started loading: $url');
          },
          onPageFinished: (String url) {
            print('Page finished loading: $url');
          },
          gestureNavigationEnabled: true,
          geolocationEnabled: false,

        );


      }),

    );
  }



ios.PNG

Manish sharma

unread,
Mar 1, 2022, 8:08:45 AM3/1/22
to Flutter Development (flutter-dev)

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/75f0b01e-d91e-45a8-8be6-f565615ee4bbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages