Loading url in web view doesn't work on web Flutter - flutter-web

I'm using flutter_inappwebview: 6.0.0-beta.22 package and I'm opening the Stripe onboarding process in an in-app web view.
While on Android emulator works as expected and the page is loaded, when I launch the web view on the web app(launched in release mode run -d chrome --release --web-hostname localhost --web-port 5000 ) the page doesn't load and on console I get the message
url is: https://connect.stripe.com/setup/c/acct_1MFXNcFwHPwkSrfO/jug2SEGbwzAq
NoSuchMethodError: method not found: 'toString' on null
js_primitives.dart:47 at a6J.aA (http://localhost:5000/main.dart.js?version=9:56217:6)
js_primitives.dart:47 at fY.Gq (http://localhost:5000/main.dart.js?version=9:82446:12)
js_primitives.dart:47 at fY.e0 (http://localhost:5000/main.dart.js?version=9:82409:6)
js_primitives.dart:47 at IQ.Cc (http://localhost:5000/main.dart.js?version=9:82306:3)
js_primitives.dart:47 at IQ.eK (http://localhost:5000/main.dart.js?version=9:82255:16)
js_primitives.dart:47 at IQ.e0 (http://localhost:5000/main.dart.js?version=9:82634:8)
js_primitives.dart:47 at Ai.Cc (http://localhost:5000/main.dart.js?version=9:82306:3)
js_primitives.dart:47 at Ai.eK (http://localhost:5000/main.dart.js?version=9:82255:16)
js_primitives.dart:47 at Ai.kE (http://localhost:5000/main.dart.js?version=9:82417:32)
js_primitives.dart:47 at Ai.wy (http://localhost:5000/main.dart.js?version=9:82382:6)
when clicking on any of the js_primitives.dart:47links on the right it shows this error
Could not load content for org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_primitives.dart (Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)
Now, the url print is from the screen initState and is correct.
This is the Screen:
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:universal_platform/universal_platform.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../utilities.dart';
class StripeOnboardScreen extends StatefulWidget {
final String onboardUrl;
const StripeOnboardScreen({Key? key, required this.onboardUrl})
: super(key: key);
#override
State<StripeOnboardScreen> createState() => _StripeOnboardScreenState();
}
class _StripeOnboardScreenState extends State<StripeOnboardScreen> {
dynamic backButton = UniversalPlatform.isWeb
? UniversalPlatform.isIOS
? CupertinoIcons.back
: Icons.arrow_back
: Icons.arrow_back;
double fontSize = Utilities.fontSize;
final GlobalKey webViewKey = GlobalKey();
InAppWebViewController? webViewController;
InAppWebViewSettings settings = InAppWebViewSettings(
javaScriptEnabled: true,
javaScriptCanOpenWindowsAutomatically: true,
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false,
allowsInlineMediaPlayback: true,
iframeAllow: "camera; microphone",
iframeAllowFullscreen: true);
late PullToRefreshController pullToRefreshController;
double progress = 0;
// Create a webview controller to control the webview and get information
// about its current state
final urlController = TextEditingController();
#override
void initState() {
super.initState();
print('url is: ${widget.onboardUrl}');
pullToRefreshController = (kIsWeb
? null
: PullToRefreshController(
settings: PullToRefreshSettings(
color: Colors.blue,
),
))!;
}
#override
void dispose() {
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
// Show a "Back" button in the app bar if the webview is displaying
// a page other than the initial page
leading: IconButton(
icon: Icon(backButton),
color: Colors.redAccent,
onPressed: () {
Navigator.pop(context);
}),
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: InAppWebView(
key: webViewKey,
initialUrlRequest: URLRequest(
url: WebUri(widget.onboardUrl, forceToStringRawValue: true)),
initialSettings: settings,
pullToRefreshController: pullToRefreshController,
onWebViewCreated: (controller) {
webViewController = controller;
},
onLoadStart: (controller, url) {
setState(() {
urlController.text = widget.onboardUrl;
});
},
onPermissionRequest: (controller, request) async {
return PermissionResponse(
resources: request.resources,
action: PermissionResponseAction.GRANT);
},
shouldOverrideUrlLoading: (controller, navigationAction) async {
var uri = navigationAction.request.url!;
if (![
"http",
"https",
"file",
"chrome",
"data",
"javascript",
"about"
].contains(uri.scheme)) {
await canLaunchUrlString(widget.onboardUrl)
? await launchUrlString(widget.onboardUrl)
: throw 'Could not launch ${widget.onboardUrl}';
// and cancel the request
return NavigationActionPolicy.CANCEL;
}
return NavigationActionPolicy.ALLOW;
},
onConsoleMessage: (controller, consoleMessage) {
print('consoleMessage is : $consoleMessage');
},
),
),
);
}
}
I added the script in the head as per docs but here is the index.html so you can have look at it
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>fixit</title>
<!-- <meta name="google-signin-client_id" content="YOUR_GOOGLE_SIGN_IN_OAUTH_CLIENT_ID.apps.googleusercontent.com">-->
<meta name="google-signin-client_id"
content="147151203258-clupo1g18oueig38uq8nts5mnkgug13e.apps.googleusercontent.com">
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">-->
<script type="application/javascript" src="/assets/packages/flutter_inappwebview/assets/web/web_support.js" defer></script>
</head>
<!--<body>-->
<body id="app-container">
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-remote-config.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "xx",
authDomain: "xx",
databaseURL: "xx",
projectId: "xx",
storageBucket: "xx",
messagingSenderId: "xx",
appId: "xx",
measurementId: "xx"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
<!-- firebase.analytics();-->
</script>
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
//navigator.serviceWorker.register("/flutter_service_worker.js");
navigator.serviceWorker.register("/firebase-messaging-sw.js");
});
}
</script>
<script src="main.dart.js?version=9" type="application/javascript"></script>
</body>
</html>
Can you spot what I'm doing wrong?
this is my flutter doctor
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.5.1 21G83 darwin-arm, locale en-IT)
• Flutter version 3.3.9 on channel stable at /Users/vincenzocalia/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b8f7f1f986 (3 weeks ago), 2022-11-23 06:43:51 +0900
• Engine revision 8f2221fbef
• Dart version 2.18.5
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/vincenzocalia/Library/Android/sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13F100
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.73.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.5.1 21G83 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
HTTP Host availability check is taking a long time...[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!

Afters stripping down the Screen to the bare minimum (So no InAppWebViewController, PullToRefreshController, no callbacks) it finally displays the link.
Unfortunately Stripe doesn't allow it to be in a iFrame so I get the web an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'.
So unless there is some settings to put in place for the plugin, I have to open it a new window for the app running on the web..

Related

When I use electron-builder to package an NSIS program, I get: Fatal error: Unable to parse version string for FileVersion

Electron-Builder Version: 22.14.5
Node Version: v16.13.1
Electron Version: 16.0.6
Electron Type (current, beta, nightly): current
Not using electron-updater
Target: nsis
Here is the console log.
Compilation succeeded.
• electron-builder version=22.14.5 os=5.10.89-1-MANJARO
• loaded configuration file=/home/aszswaz/document/notebook/code-example/webpack-electron-vue/config/electron-builder-win.js
• Specified application directory equals to project dir — superfluous or wrong configuration appDirectory=./
• writing effective config file=dist/electron-builder/builder-effective-config.yaml
• skipped dependencies rebuild reason=npmRebuild is set to false
• packaging platform=win32 arch=x64 electron=v16.0.6 appOutDir=dist/electron-builder/win-unpacked
• asar usage is disabled — this is strongly not recommended solution=enable asar and use asarUnpack to unpack files that must be externally available
• asar usage is disabled — this is strongly not recommended solution=enable asar and use asarUnpack to unpack files that must be externally available
⨯ cannot execute cause=exit status 1
errorOut=Fatal error: Unable to parse version string for FileVersion
0024:fixme:ver:GetCurrentPackageId (0032FE94 00000000): stub
command=wine /home/aszswaz/.cache/electron-builder/winCodeSign/winCodeSign-2.6.0/rcedit-ia32.exe /home/aszswaz/document/notebook/code-example/webpack-electron-vue/dist/electron-builder/win-unpacked/hanna.exe --set-version-string FileDescription hanna --set-version-string ProductName hanna --set-version-string LegalCopyright aszswaz --set-file-version v1.0.0 --set-product-version 1.0.0.0 --set-version-string InternalName hanna --set-version-string OriginalFilename '' --set-version-string CompanyName aszswaz --set-icon /home/aszswaz/document/notebook/code-example/webpack-electron-vue/public/icon.ico
workingDir=
This is the config file used.
module.exports = {
appId: "cn.aszswaz.demo.webpack-electron-vue",
productName: "hanna",
copyright: "aszswaz",
asar: false,
files: [
"dist/app/*",
"!**/node_modules/vue/*",
"!**/node_modules/vue-router/*"
],
artifactName: "${productName}-${arch}-${version}.${ext}",
directories: {
app: "./",
output: "./dist/electron-builder"
},
win: {
target: "nsis",
icon: "public/icon.ico"
},
nsis: {
oneClick: false,
perMachine: true,
allowToChangeInstallationDirectory: true
},
npmRebuild: false,
buildVersion: "v1.0.0",
electronCompile: false,
electronDownload: {
version: "16.0.6",
platform: "win32",
arch: "x64",
cache: process.cwd() + "/cache"
},
electronVersion: "v16.0.6"
}
What is the reason for this error? How can I fix this error?

Process is not defined for Electron's Getting Started App [duplicate]

This question already has answers here:
Unable to use Node.js APIs in renderer process
(2 answers)
Closed 1 year ago.
I am trying to get started with Electron. I was already able to run all simple examples. They all work as expected. When I try to follow the Quick Start Guide I experience the same issue as mentioned in this question: The app launches properly, but does not display the versions of node Chrome and Electron. When I look into the developing tools I see this error:
Uncaught ReferenceError: process is not defined
at index.html:14
However, I have set nodeIntegration to true.
Why is it still not working?
Versions:
npm 7.6.3
node v14.16.0
chromium 89.0.4389.82
Operating System:
Ubuntu 20.04.2 LTS.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body style="background: white;">
<h1>Hello World!</h1>
<p>
We are using node
<script>document.write(process.versions.node)</script>,
Chrome
<script>document.write(process.versions.chrome)</script>,
and Electron
<script>document.write(process.versions.electron)</script>.
</p>
</body>
</html>
main.js
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
package.json
{
"name": "my-electron-app",
"version": "0.1.0",
"author": "username",
"description": "My Electron app",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^12.0.0"
}
}
Try to set this value when creating your BrowserWindow:
webPreferences: { nodeIntegration: true, contextIsolation: false }
A new major Electron version has been released which broke the tutorial.
The specific breaking change is a new default value of contextIsolation flag.
For more details, see this GitHub issue.

Unhandled Exception: MissingPluginException(No implementation found for method listenForCode on channel sms_autofill)

I'm working on a project and before merging the code with my teammates, package sms_autofill runs normally, but after the code got merged, I've already run flutter clean but it still shows two erros as below:
Unhandled Exception: MissingPluginException(No implementation found for method listenForCode on channel sms_autofill)
and
Unhandled Exception: MissingPluginException(No implementation found for method getAppSignature on channel sms_autofill)
My code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rentto_tenant/model/auth.dart';
import 'package:rentto_tenant/repository/auth_repository.dart';
import 'package:rentto_tenant/util/exception/ResponseException.dart';
import 'package:rentto_tenant/view/welcome/welcome.dart';
import 'package:rentto_tenant/view/home/home.dart';
import 'package:rentto_tenant/widget/loaders/color_loader_3.dart';
import 'package:rentto_tenant/widget/loaders/color_loader_4.dart';
import 'package:rentto_tenant/widget/loading_widget.dart';
import 'package:sms_autofill/sms_autofill.dart';
import 'package:pin_code_text_field/pin_code_text_field.dart';
import '../../constant/color.dart';
import '../../constant/dimen.dart';
class SMSVerificationPage extends StatefulWidget {
final String uuid;
final String phoneNumber;
final String password;
final String requestType;
const SMSVerificationPage(
{Key key, this.uuid, this.phoneNumber, this.password, this.requestType})
: super(key: key);
#override
_SMSVerificationPageState createState() => _SMSVerificationPageState();
}
class _SMSVerificationPageState extends State<SMSVerificationPage>
with CodeAutoFill {
TextEditingController pinCodeController = new TextEditingController();
TextEditingController autoFillCodeController = new TextEditingController();
_resendCode() async {
_loadingController.startLoading();
try {
String _uuid =
await AuthUserRepository.of(context).resendCode(widget.phoneNumber);
_loadingController.stopLoading();
setState(() {
_codeResent = true;
_codeExpiresInXMin = 5;
});
startTimer();
print(_uuid);
} on ResponseException catch (e) {
print(e.response.statusCode);
print(e.response.body);
} catch (e) {
print(e.toString());
} finally {
_loadingController.stopLoading();
}
}
_verifyCode() async {
_loadingController.startLoading();
try {
AuthUser auth = await AuthUserRepository.of(context).verifyUser(
widget.uuid,
pinCodeController.text,
widget.password,
widget.requestType);
// store Auth Tokens
print(auth.toJson());
// navigate
_loadingController.stopLoading();
if (widget.requestType == "reset_password") {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => HomePage()),
(route) => false);
} else {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => WelcomePage()),
(route) => false);
}
} on ResponseException catch (e) {
_codeErr = true;
print(e.response.statusCode);
print(e.response.body);
} catch (e) {
_codeErr = true;
print(e.toString());
throw (e);
} finally {
_loadingController.stopLoading();
}
}
String appSignature;
String otpCode;
bool _codeErr = false;
bool _codeResent = false;
Timer _timer;
int _codeExpiresInXMin = 5;
void startTimer() {
const oneMin = const Duration(minutes: 1);
_timer = new Timer.periodic(
oneMin,
(Timer timer) => setState(
() {
if (_codeExpiresInXMin < 1) {
timer.cancel();
} else {
_codeExpiresInXMin = _codeExpiresInXMin - 1;
}
},
),
);
}
#override
void codeUpdated() {
setState(() {
otpCode = code;
pinCodeController.text = code;
});
}
#override
void initState() {
startTimer();
listenForCode();
SmsAutoFill().getAppSignature.then((signature) {
setState(() {
appSignature = signature;
});
});
super.initState();
}
#override
void dispose() {
_timer.cancel();
cancel();
super.dispose();
}
final _loadingController = LoadingController();
#override
Widget build(BuildContext context) {
return LoadingWidget(
controller: _loadingController,
child: Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 15.0, bottom: 8.0),
child: Image(
image: AssetImage(
"assets/images/Logo.png",
),
width: 93,
height: 110,
),
),
Container(
margin: EdgeInsets.only(bottom: 30),
child: Text(
"RENTTO",
style: Theme.of(context).textTheme.headline4.copyWith(
color: AppColors.genericColor,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
"Enter Verifcation code",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline5,
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Text(
"If you're having any issue, contact to RENTTO",
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.only(top: 40, bottom: 25),
child: PinCodeTextField(
controller: pinCodeController,
maxLength: 6,
pinBoxWidth: 50,
pinBoxHeight: 50,
pinBoxRadius: 10,
pinBoxBorderWidth: 1,
autofocus: true,
highlight: true,
highlightColor: AppColors.genericColor,
hasError: _codeErr,
errorBorderColor: Colors.red,
pinTextStyle: TextStyle(
color: AppColors.genericColor,
fontSize: 25,
fontWeight: FontWeight.bold),
keyboardType: TextInputType.number,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: _codeResent
? Text(
'OTP Code has been resent! Please fill in the code in ' +
_codeExpiresInXMin.toString() +
' minutes.',
style: TextStyle(
fontSize: 14,
color: AppColors.genericColor,
),
textAlign: TextAlign.center,
)
: Text(
'OTP Code has been sent! Please check your message and fill in the code in ' +
_codeExpiresInXMin.toString() +
' minutes.',
style: TextStyle(
fontSize: 14,
color: AppColors.genericColor,
),
textAlign: TextAlign.center,
),
),
FlatButton(
onPressed: () {
setState(() {
_loadingController.startLoading();
});
_resendCode();
},
child: Text("Resend Code",
style: TextStyle(
fontSize: 17,
color: AppColors.genericColor,
fontWeight: FontWeight.w600)),
),
Padding(
padding: const EdgeInsets.only(top: 30.0, bottom: 30.0),
child: RaisedButton(
padding: EdgeInsets.symmetric(
horizontal: 120, vertical: 15),
onPressed: () {
setState(() {
_loadingController.startLoading();
});
_verifyCode();
},
child: Text(
"CONTINUE",
style: TextStyle(
fontSize: AppDimens.btnTextSize,
),
),
color: AppColors.primaryColors,
),
)
],
),
),
),
),
),
);
}
}
flutter doctor -v:
[✓] Flutter (Channel master, 1.21.0-6.0.pre.3, on Linux, locale en_US.UTF-8)
• Flutter version 1.21.0-6.0.pre.3 at /home/veasnawt/Flutter/flutter
• Framework revision ddb8e6e3bf (24 hours ago), 2020-07-22 20:00:07 -0700
• Engine revision dcc9a4048d
• Dart version 2.9.0 (build 2.9.0-21.0.dev 9dca49e71e)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /home/veasnawt/Android/Sdk
• Platform android-30, build-tools 29.0.3
• Java binary at: /snap/android-studio/90/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[✓] Android Studio (version 3.6)
• Android Studio at /snap/android-studio/88/android-studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Android Studio (version 4.0)
• Android Studio at /snap/android-studio/90/android-studio
• Flutter plugin version 47.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] Connected device (4 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Linux (desktop) • linux • linux-x64 • Linux
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 81.0.4044.129
• No issues found!
pubspec.yaml:
name: rentto_tenant
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_i18n: ^0.18.0
json_annotation: ^3.0.1
http: ^0.12.2
provider: ^4.3.1
flutter_dotenv: ^2.1.0
pin_code_text_field: ^1.2.1
sms_autofill: ^1.2.1
font_awesome_flutter: ^8.8.1
flutter_facebook_login: ^3.0.0
intro_slider: ^2.3.1
fluttertoast: ^7.0.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.10.0
json_serializable: ^3.3.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- .env
- assets/images/
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
I don't know what's wrong with it, I've tried searching on the internet and it seems there is no solution related to it. enter code here
Finally, I know what the problem is.
The package sms_autofill itself is not the cause of the problem, the problem is that the package flutter_facebook_login was installed and being unused. Remove or use it properly will solve the problem.

Using monaco-editor with typescript without webpack in an electron project

I'm trying to use monaco-editor in an electron typescript project. I installed it via
npm install -D monaco-editor.
I import it with import { editor } from "monaco-editor"; My IDE (WebStorm) doesn't complain about an unfound module, however after running the app I get the following error:
Uncaught Error: Cannot find module 'monaco-editor' from internal/modules/cjs/loader.js:801 in the console.
I have already tried
Downloading the package manualy
Reinstalling the module
Cloning the code from the official repository
I was able to run official samples, those however use pure javascript. I also do not use WebPack. I suppose that should not make a difference, however it is used in all getting started and installation guides.
What is the source of that error and how can I fix it?
P.S. You can find the full code on github if you need more context
I managed to make it work.
So for those who try:
tsconfig.json
Try to make the typescript compiler ignore the errors in the monaco library.
"compilerOptions": {
"checkJs": false,
"skipLibCheck": true,
},
rollup.config.js
Make the bundler accept importing css files, also adding the line inlineDynamicImports: true fix the compile. I am not sure what the impact is yet.
import rollupPluginCssOnly from 'rollup-plugin-css-only'
export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js',
inlineDynamicImports: true
},
plugins: [
rollupPluginCssOnly({
output: 'public/build/extra.css'
}),
html page
I use svelte but this can be converted to plain html easily (using for example getDocumentById to get the element).
<script lang="ts">
import { onMount } from 'svelte'
import './extra.css'
import * as monaco from 'monaco-editor'
var containerElt: HtmlDivElement
onMount(() => {
monaco.editor.create(containerElt, {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
'\n',
),
language: 'javascript',
})
})
</script>
<style>
div {
width: 100%;
height: 100%;
}
</style>
<svelte:head />
<div bind:this={containerElt} />

flutter i18n plugin not working in android studio 3.4.0

flutter i18n plugin not working in android studio 3.4.0
i18n.dart file not generated automatically in Android Studio
version of AS 3.4.0
flutter -version 1.5.4
flutter i18n-version 1.0.2
You can use following approach. It's tested with flutter web and mobile
Include this in pubspec.yaml
dependencies:
#i18n
flutter_i18n:
flutter:
assets:
- assets/i18n/
Dummy main page widget:
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new MaterialApp(
//i18n stuff
localizationsDelegates: [
FlutterI18nDelegate(
useCountryCode: false,
fallbackFile: 'en',
path: 'assets/i18n',
),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: new LoginPage(),
);
}
Put this in assets/i18n/en.json
{
"login_screen": {
"button": {
"login": "LOGIN"
}
}
}
Now use these strings as following:
Text(FlutterI18n.translate(
context, 'login_screen.button.login'))

Resources