Posts

Showing posts from August, 2020

Flutter change screen orientations

Screen orientation is one of best part in app. Some games always be landscape and some of business based app always be portrait orientation.  For Portrait orientation: WidgetsFlutterBinding.ensureInitialized();    await SystemChrome.setPreferredOrientations(     [DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]); For Landscape orientation: WidgetsFlutterBinding.ensureInitialized();    await SystemChrome.setPreferredOrientations(     [DeviceOrientation. landscapeLeft , DeviceOrientation. landscapeRight ]);

Flutter - Ignore pointer and absorb pointer.

 Absorb Pointer A widget that absorbs pointers during hit testing. When absorbing is true, this widget prevents its sub tree from receiving pointer events by terminating hit testing at itself.  Click here to know more It's like enable or disable field by depends on the value. Ignore Pointer A widget that is invisible during hit testing. When ignoring is true, this widget (and its sub tree) is invisible to hit testing. Click here to know more To Ignore the whole drag, click, swipe and all types of event on entire the child classes.  Example click here

Flutter web view

 Hey friends, have a happy weekend. After a long gap of lock down, I just came back. I know 2020 will be so hard for everyone. Hope everything fine soon.  Today we gonna see the flutter web view. In android we used call WebView. It's similar like that. Let's dive on that. First of all, add the library in pubspec.yaml webview_flutter: ^0.3.21 then If you want to load the html page from your assets, you add into pubspec.yaml like below:   assets:     - assets/sample.html Please be careful with intent, because yaml is very sensed on that. Either it won't be work. you can see the full example in my gist: https://gist.github.com/vignarajj/59a518610a2bfeb09ad4b0b6d8fe7c69 If you directly call url, just call like that, WebView(           initialUrl: 'https://google.com',           javascriptMode: JavascriptMode.unrestricted,           onWebViewCreated: (WebViewController webViewController) {             _controller.complete(webViewController);           },         ));