Search
 
SCRIPT & CODE EXAMPLE
 

DART

how to craete function in flutter

import 'package:flutter/material.dart';
import 'package:flutter_web_view/flutter_web_view.dart';

class ShopClass extends StatefulWidget {
  @override
  ShopClassState createState() => new ShopClassState();
}

class ShopClassState extends State<ShopClass> {
  String _redirectedToUrl;
  FlutterWebView flutterWebView = new FlutterWebView();
  bool _isLoading = false;

  @override
  initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Widget leading;
    if (_isLoading) {
      leading = new CircularProgressIndicator();
    }
    var columnItems = <Widget>[
      new MaterialButton(
          onPressed: launchWebViewExample, child: new Text("Launch"))
    ];
    if (_redirectedToUrl != null) {
      columnItems.add(new Text("Redirected to $_redirectedToUrl"));
    }
    var app = new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          leading: leading,
        ),
        body: new Column(
          children: columnItems,
        ),
      ),
    );
    return app;
  }


  void launchWebViewExample() {
    if (flutterWebView.isLaunched) {
      return;
    }

    flutterWebView.launch("https://apptreesoftware.com",
        headers: {
          "X-SOME-HEADER": "MyCustomHeader",
        },
        javaScriptEnabled: false,
        toolbarActions: [
          new ToolbarAction("Dismiss", 1),
          new ToolbarAction("Reload", 2)
        ],
        barColor: Colors.green,
        tintColor: Colors.white);
    flutterWebView.onToolbarAction.listen((identifier) {
      switch (identifier) {
        case 1:
          flutterWebView.dismiss();
          break;
        case 2:
          reload();
          break;
      }
    });
    flutterWebView.listenForRedirect("mobile://test.com", true);

    flutterWebView.onWebViewDidStartLoading.listen((url) {
      setState(() => _isLoading = true);
    });
    flutterWebView.onWebViewDidLoad.listen((url) {
      setState(() => _isLoading = false);
    });
    flutterWebView.onRedirect.listen((url) {
      flutterWebView.dismiss();
      setState(() => _redirectedToUrl = url);
    });
  }



  void reload() {
    flutterWebView.load(
      "https://google.com",
      headers: {
        "X-SOME-HEADER": "MyCustomHeader",
      },
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: add firest in list in dart 
Dart :: dart list get by index 
Dart :: convert seconds to minutes in Dart 
Dart :: dart uzunlik 
Dart :: flutter container rounded corners 
Swift :: firebase crashlytics dsym missing 
Swift :: swift ui int to binary 
Swift :: save date to userdefaults swift 
Swift :: swift ui square root 
Swift :: update cell value swift 
Swift :: swift for loop index 
Swift :: swift xcode debug cannot see code backtrace 
Swift :: xcode perform action when return key pressed text field 
Swift :: swift navigation bar title font 
Swift :: fizzbuzz in swift 
Swift :: Return multiple value of different types swift 
Swift :: swift close app 
Swift :: swiftui full screen sheet 
Swift :: swift 5 only the day number from date 
Swift :: swift sleep milliseconds 
Swift :: array swift 
Swift :: string value of enum swift 
Swift :: enviroment dissmiss swiftui 
Swift :: remove all add TapGestureRecognizer swift 
Swift :: swiftlint 
Swift :: ios UIButton change image 
Swift :: Swift for-in Loop 
Swift :: swift lazy 
Swift :: convert nscfstring to dictionary swift 
Swift :: xcode how to get aspect ratio of device 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =