I use the flutter_inappwebview plugin to run a WebView (PostUrl). but I found an error when displaying my web. Here's an example of my coding:
import 'dart:async';
import 'dart:convert' show utf8;
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:smartmosque/Api/ApiServer.dart';
import 'package:smartmosque/Utils/Global.dart';
class PaymentLinkAjaPage extends StatefulWidget {
final String token;
PaymentLinkAjaPage({this.token});
#override
_PaymentLinkAjaPageState createState() => _PaymentLinkAjaPageState();
}
class _PaymentLinkAjaPageState extends State<PaymentLinkAjaPage> {
InAppWebViewController webView;
String url = "";
double progress = 0;
void actionBack() {
if (url.length > 100) {
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
} else {
Navigator.pop(context);
}
}
#override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
actionBack();
return Future.value(true);
},
child: Scaffold(
backgroundColor: Global.primaryRed,
appBar: AppBar(
title: Text("Infak Link Aja!"),
elevation: 0,
leading: IconButton(
icon: Icon(Icons.clear),
onPressed: () {
actionBack();
}),
),
body: Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20, right: 20),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
child: InAppWebView(
initialHeaders: {},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true,
useShouldOverrideUrlLoading: false)),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
var encodetext = utf8.encode("message=${widget.token}");
Uint8List postdata = Uint8List.fromList(encodetext);
webView.postUrl(url: urlWebLinkAja, postData: postdata);
},
androidOnPermissionRequest:
(InAppWebViewController controller, String origin,
List<String> resources) async {
return PermissionRequestResponse(
resources: resources,
action: PermissionRequestResponseAction.GRANT);
},
onReceivedServerTrustAuthRequest:
(controller, challenge) async {
return ServerTrustAuthResponse(
action: ServerTrustAuthResponseAction.PROCEED);
},
onLoadStart:
(InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
// print("urlstart: $url");
});
},
onLoadStop: (controller, url) async {
setState(() {
this.url = url;
});
},
onProgressChanged:
(InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
))
],
),
),
),
);
}
}
and here's the error log:
E/OpenGLRenderer( 5918): GL error: Out of memory!
F/OpenGLRenderer( 5918): glFinish error! GL_OUT_OF_MEMORY (0x505)
W/google-breakpad( 5918): ### ### ### ### ### ### ### ### ### ### ### ### ###
W/google-breakpad( 5918): Chrome build fingerprint:
W/google-breakpad( 5918): 70.0.3538.110
W/google-breakpad( 5918): 353811052
W/google-breakpad( 5918): ### ### ### ### ### ### ### ### ### ### ### ### ###
F/libc ( 5918): Fatal signal 6 (SIGABRT), code -6 in tid 6041 (RenderThread), pid 5918 (gma.example)
Softversion: PD1731F_EX_A_1.18.3
Time: 2020-09-28 15:17:37
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'vivo/1724/1724:8.1.0/OPM1.171019.011/compil08311518:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 5918, tid: 6041, name: RenderThread >>> com.example.test <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'glFinish error! GL_OUT_OF_MEMORY (0x505)'
x0 0000000000000000 x1 0000000000001799 x2 0000000000000006 x3 0000000000000008
x4 0000007b2cd44588 x5 0000007b2cd44588 x6 0000007b2cd44588 x7 0000007b2cd44588
x8 0000000000000083 x9 0000000010000000 x10 0000007b2cd43cb0 x11 8f38f30250d84677
x12 8f38f30250d84677 x13 0000000000000000 x14 ffffffffffffffdf x15 8f38f30250d84677
x16 0000005f418bffa8 x17 0000007bd2ec4134 x18 8f38f30250d84677 x19 000000000000171e
x20 0000000000001799 x21 0000000000000083 x22 0000007bd29a9a70 x23 0000000000000502
x24 0000007bd29a9b3e x25 0000000000000505 x26 0000007bd29a9b24 x27 0000007bd29a9b3e
x28 0000000000000505 x29 0000007b2cd43cf0 x30 0000007bd2e6a630
sp 0000007b2cd43cb0 pc 0000007bd2e6a658 pstate 0000000060000000
backtrace:
#00 pc 000000000001e658 /system/lib64/libc.so (abort+120)
#01 pc 00000000000083e4 /system/lib64/liblog.so (__android_log_assert+296)
#02 pc 00000000000468fc /system/lib64/libhwui.so (android::uirenderer::debug::GlesErrorCheckWrapper::assertNoErrors(char const*)+384)
#03 pc 0000000000089b00 /system/lib64/libhwui.so (android::uirenderer::Caches::flush(android::uirenderer::Caches::FlushMode)+164)
#04 pc 00000000000752fc /system/lib64/libhwui.so (android::uirenderer::renderthread::Bridge_destroyHardwareResources(android::uirenderer::renderthread::destroyHardwareResourcesArgs*)+12)
#05 pc 0000000000076934 /system/lib64/libhwui.so (android::uirenderer::renderthread::MethodInvokeRenderTask::run()+24)
#06 pc 0000000000076cc8 /system/lib64/libhwui.so (android::uirenderer::renderthread::SignalingRenderTask::run()+28)
#07 pc 0000000000077c18 /system/lib64/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+336)
#08 pc 0000000000011590 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+276)
#09 pc 00000000000aa03c /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+136)
#10 pc 0000000000077968 /system/lib64/libc.so (__pthread_start(void*)+36)
#11 pc 000000000001fa30 /system/lib64/libc.so (__start_thread+68)
Lost connection to device.
Running flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18363.1082], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.6)
[√] VS Code (version 1.49.2)
[√] Connected device (1 available)
• No issues found!
Related
I'm using Flutter stripe_checkout: ^1.0.0 and saw some odd behaviour.
When the checkout button is clicked just once, the screen would turn blank with the following printout. On Stripe dashboard, it says, "Incomplete - The customer has not entered their payment method'.
I/flutter (32631): Checkout session id cs_test_a10k5Lsopaz9JupfebE9pW77ZgUpucfzCrh1WTKX9KcApdbKztnZiz1SKe
I/WebViewFactory(32631): Loading com.google.android.webview version 83.0.4103.106 (code 410410681)
I/cr_VariationsUtils(32631): Requesting new seed from IVariationsSeedServer
I/cr_LibraryLoader(32631): Loaded native library version number "83.0.4103.106"
I/cr_CachingUmaRecorder(32631): Flushed 3 samples from 3 histograms.
I/TetheringManager(32631): registerTetheringEventCallback:com.healthcare.jaaba
W/GooglePlayServicesUtil(32631): Google Play Store is missing.
W/GooglePlayServicesUtil(32631): Google Play Store is missing.
W/GooglePlayServicesUtil(32631): Google Play Store is missing.
W/GooglePlayServicesUtil(32631): Google Play Store is missing.
E/cr_PlatformSer-Internal(32631): UsageReporting query failed
W/ealthcare.jaab(32631): Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (greylist, reflection, allowed)
D/HostConnection(32631): HostConnection::get() New Host Connection established 0xf4e7e280, tid 752
E/cr_PlatformSer-Internal(32631): Unable to determine Safe Browsing user opt-in preference
D/HostConnection(32631): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
D/EGL_emulation(32631): eglCreateContext: 0xf4e7c140: maj 3 min 0 rcv 3
D/EGL_emulation(32631): eglMakeCurrent: 0xf4e7c140: ver 3 0 (tinfo 0xaf33b210) (first time)
D/EGL_emulation(32631): eglMakeCurrent: 0xf4e60d10: ver 3 0 (tinfo 0xf51b1d50) (first time)
W/Gralloc4(32631): allocator 3.x is not supported
I/VideoCapabilities(32631): Unsupported profile 4 for video/mp4v-es
W/cr_MediaCodecUtil(32631): HW encoder for video/avc is not available on this device.
D/EGL_emulation(32631): eglCreateContext: 0xf4e7f1d0: maj 3 min 0 rcv 3
I/ealthcare.jaab(32631): NativeAlloc concurrent copying GC freed 50165(3378KB) AllocSpace objects, 15(428KB) LOS objects, 49% free, 3769KB/7539KB, paused 2.245ms total 147.024ms
W/ealthcare.jaab(32631): Reducing the number of considered missed Gc histogram windows from 124 to 100
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
However, when the checkout button is clicked 3 - 5 times continuously, the card form appears and the payment would be successful.
I/flutter (32631): Checkout session id cs_test_a1ZwZrvL4812TEpjFwQ649RMYjirJr9TMwQVZ29JYrjGj54gmqkCtTyfTW
I/flutter (32631): Checkout session id cs_test_a13D23W9EY1SgLBqYIZLAHTvFBcHKY1wUIiZdr3Kb6XPNsrrLEfj3KJjkj
I/ealthcare.jaab(32631): NativeAlloc concurrent copying GC freed 7125(419KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3431KB/6863KB, paused 1.352ms total 189.441ms
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/flutter (32631): Checkout session id cs_test_a1QsxT2t7H68MpvgLinDukwOBzwW1W21ktnbQdqB25R6t2b0TE5mO4u9jj
I/flutter (32631): Checkout session id cs_test_a1o2VPwBSq0RRW6PlSKnGr554hoWFIOrPy1NZWnLveMqAZyLX6iVYKFr0y
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/flutter (32631): Checkout session id cs_test_a1uWleO9v9VAwUAra957z8uHbpOwNyp24nZYgAQ2aOLHqwt3hBcOtAg8Yf
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/ (1)
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/fingerprinted/js/stripe-a07f9e62b0b55658b30abedf1005cae0.js (1)
I/chatty (32631): uid=10139(com.healthcare.jaaba) identical 1 line
I/chromium(32631): [INFO:CONSOLE(1)] "Unrecognized feature: 'payment'.", source: https://js.stripe.com/v3/fingerprinted/js/stripe-a07f9e62b0b55658b30abedf1005cae0.js (1)
I/Choreographer(32631): Skipped 31 frames! The application may be doing too much work on its main thread.
I/chromium(32631): [INFO:CONSOLE(265)] "Uncaught ReferenceError: PaymentRequest is not defined", source: https://pay.google.com/gp/p/js/pay.js (265)
Flutter Application: checkout_screen.dart
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:stripe_checkout/stripe_checkout.dart';
import 'package:flutter/material.dart';
import '../../../../utils/env.dart';
import '../widgets/example_scaffold.dart';
import '../../../../utils/api_endpoints.dart';
import 'platforms/stripe_checkout.dart' if (dart.library.js)
'platforms/stripe_checkout_web.dart';
class CheckoutScreenExample extends StatefulWidget {
const CheckoutScreenExample({Key? key}) : super(key: key);
#override
_CheckoutScreenExample createState() => _CheckoutScreenExample();
}
class _CheckoutScreenExample extends State<CheckoutScreenExample> {
#override
Widget build(BuildContext context) {
return ExampleScaffold(
title: 'Checkout Page',
padding: const EdgeInsets.all(16),
children: [
const SizedBox(height: 120),
Center(
child: ElevatedButton(
onPressed: checkout,
child: const Text('Open Checkout'),
),
)
],
);
}
Future<void> checkout() async {
final String sessionId = await _createCheckoutSession();
final result = await redirectToCheckout(
context: context,
sessionId: sessionId,
publishableKey: stripePublishableKey,
successUrl: 'https://checkout.stripe.dev/success',
canceledUrl: 'https://checkout.stripe.dev/cancel',
);
if (mounted) {
final text = result.when(
success: () => 'Paid successfully',
canceled: () => 'Checkout canceled',
error: (e) => 'Error $e',
redirected: () => 'Redirected successfully',
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(text)),
);
}
}
Future<String> _createCheckoutSession() async {
final stripePayURL = Uri.parse(ApiUrl.stripePayUrl);
final response = await http.get(
stripePayURL,
headers: <String, String>{'Authorization': 'Bearer ' + token,
},
);
final Map<String, dynamic> bodyResponse = json.decode(response.body);
final id = bodyResponse['checkout_session_id'] as String;
debugPrint('Checkout session id $id');
return id;
}
}
Flask Backend: billing.py
#api_blueprint.route('/stripe_pay', methods=['GET'])
#token_auth.login_required
def stripe_pay():
cart_id = basic_auth.current_user().id
transaction = Transaction.query.filter(Transaction.cart_id==cart_id).first()
price = stripe.Price.create(
unit_amount=transaction.count_grand_total(),
currency=transaction.currency,
)
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=[{
'price': price,
'quantity': 1,
}],
mode='payment',
success_url=url_for('api.success', cart_id=cart_id, _external=True) + '?cart_id=cart_id' + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=url_for('home.index', _external=True),
)
return jsonify ({
'checkout_session_id': session['id'],
'checkout_public_key': checkout_public_key,
'cart_id': int(cart_id)
})
I would appreciate if someone show me how to fix this. Thank you.
I'm trying to navigate on my webview but especially on some sites e.g Twitter, and Instagram it stays stuck (You can see the message in the log section). But it works for google, e.a.
Let's consider that I'm running "loadUrl()" for twitter.com again and again. It can load the site successfully. Then I loaded google.com. After that, I tapped the navigationBack which is running goBack() func. It stucks like in logs. But for vice versa, I can go back to google.com
Here are my code snippets:
Future<void> goToSite(String siteUrl) async {
await _controller.future;
final WebViewRequest request = WebViewRequest(
uri: Uri.parse(url),
method: WebViewRequestMethod.get,
);
await _webController.loadRequest(request);
}
Widget browser() {
return WebView(
initialUrl: 'https://${_urlController.text.toLowerCase()}',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
if (!_controller.isCompleted) {
_controller.complete(webViewController);
_webController = webViewController;
}
print("web created");
},
onProgress: (int progress) {
print('WebView is loading (progress : $progress%)');
if (progress == 100) {
notify();
}
},
navigationDelegate: (NavigationRequest request) {
print('allowing navigation to $request');
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
},
gestureNavigationEnabled: true,
backgroundColor: const Color(0x00000000),
);
}
I'm using this method to navigate:
await _webController.goBack();
await _webController.goForward();
When I tapped goBack I got this repetitive error:
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x152efaee0 - ProcessAssertion: Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=10293, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x152efaf40 - ProcessAssertion: Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=10293, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
flutter: Page started loading: https://mobile.twitter.com/
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x152efb060 - ProcessAssertion: Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=10294, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x152efb0c0 - ProcessAssertion: Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=10294, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
flutter: Page started loading: https://mobile.twitter.com/
I couldn't find the reason. How can I fix this issue?
this is my code:
void main() {
testWidgets("Localiza os widgets na home", (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: HomeView()));
final Finder drawer = find.byType(IconButton);
await tester.tap(drawer);
expect(drawer, findsOneWidget);
await tester.pumpAndSettle();
final Finder listTileDrawer = find.byType(ListTile);
expect(listTileDrawer, findsNWidgets(5));
final Finder listViewDrawer = find.byType(ListView);
expect(listViewDrawer, findsOneWidget);
});
testWidgets("Valida se snackBar está sendo exibida corretamente", (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
body: BotaoRedirecionamentoExterno(
url: 'url invalida',
texto: 'teste',
))));
final botao = find.byType(BotaoRedirecionamentoExterno);
await tester.tap(botao);
await tester.pumpAndSettle();
final Finder snackBar = find.byType(SnackBar);
expect(snackBar, findsOneWidget);
});
}
When I run: test/view/home/home_widget_test.dart --no-sound-null-safety it works as expected:
I/flutter (11181): 00:01 +1: Valida se snackBar está sendo exibida corretamente
I/flutter (11181): 00:02 +2: All tests passed!
But when I try: flutter test --no-sound-null-safety:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
Expected: exactly one matching node in the widget tree
Actual: _WidgetTypeFinder:<zero widgets with type "SnackBar" (ignoring offstage widgets)>
Which: means none were found but one was expected
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/macos/Desktop/portal-agro-sp-master/test/view/home/home_widget_test.dart:33:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/macos/Desktop/portal-agro-sp-master/test/view/home/home_widget_test.dart line 33
The test description was:
Valida se snackBar está sendo exibida corretamente
════════════════════════════════════════════════════════════════════════════════════════════════════
00:26 +25 -1: /Users/macos/Desktop/portal-agro-sp-master/test/view/home/home_widget_test.dart: Valida se snackBar está sendo exibida corretamente [E]
Test failed. See exception logs above.
The test description was: Valida se snackBar está sendo exibida corretamente
I need to be able to run all my tests together due to a customer requirement. I already have more than 23 tests ready and this is the first time this has happened.
Does anyone know why this is happening and a way to solve it ?
I'm creating a custom MaterialColor object but it's throwing that error.
colors.dart (where I'm creating the MaterialColor object)
import 'package:flutter/material.dart';
class JarsColors {
static const MaterialColor palette = MaterialColor(
0xFF276678,
<int, Color> {
0: Color(0xFFF6F5F5),
100: Color(0xFFD3E0EA),
400: Color(0xFF1687A7),
500: Color(0xFF276678),
}
);
}
main.dart
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: JarsColors.palette,
),
home: JarsHome(title: 'Hello'),
);
}
}
Error output:
The following _CastError was thrown building MyApp(dirty):
Null check operator used on a null value
The relevant error-causing widget was
MyApp
When the exception was thrown, this was the stack
#0 new ThemeData
#1 MyApp.build
#2 StatelessElement.build
#3 ComponentElement.performRebuild
#4 Element.rebuild
flutter doctor output
λ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.928], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.55.2)
[√] Connected device (3 available)
• No issues found!
I managed to make it work by adding more shades to the MaterialColor swatch argument:
class JarsColors {
static const MaterialColor palette = MaterialColor(
0xFF276678,
<int, Color> {
50: Color(0xFFF6F5F5),
100: Color(0xFFD3E0EA),
200: Color(0xFFD3E0EA),
300: Color(0xFFD3E0EA),
400: Color(0xFF1687A7),
500: Color(0xFF276678),
600: Color(0xFFD3E0EA),
700: Color(0xFF1687A7),
}
);
}
With the help of: https://api.flutter.dev/flutter/material/MaterialColor-class.html
Nonetheless I can't find an explanation to this. It'd be great to know.
To keep answer short and straight forward, when defining MaterialColor you must start from 50, then 100 and increments in interval of 100 to 800 is enough to allow you to use it without null check errors, check this one how they did it here
How to define and use custom MaterialColor in flutter
**I use Flutter Downloader Package After complete download some file , my app closes automatically and disconnecte to the android studio. Any one help me to find soltutions.
final status = await Permission.storage.request();
if (status.isGranted) {
await downloadPDF();
}
downloadPDF() async {
final externalDir = await getExternalStorageDirectory();
taskId = await FlutterDownloader.enqueue(
url: pdfURL,
savedDir: externalDir.path,
fileName: "Flamingo Order Details",
showNotification: true,
openFileFromNotification: true,
);
}
Here is my console error:
I/flutter (15913): Fatal: could not find callback
F/libc (15913): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 15956 (1.raster), pid 15913 (le.order_system)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'motorola/chef/chef_sprout:10/QPTS30.61-18-16-8/03acd:user/release-keys'
Revision: 'pvt'
ABI: 'arm64'
Timestamp: 2021-04-23 16:39:38+0530
pid: 15913, tid: 15956, name: 1.raster >>> com.example.order_system <<<
uid: 10870
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
x0 000000741e5a6478 x1 00000074841cfa00 x2 0000000000000001 x3 0000000000000000
x4 0000000000000000 x5 00000000ffffffff x6 00000000ffffffff x7 0000000b96c6a75c
x8 0000000080000081 x9 658adf78f7e836ee x10 0000000000000000 x11 0000000000000000
x12 0000000000000001 x13 000000747b19fe80 x14 0000007489a0a280 x15 0000000000000000
x16 000000747b19b050 x17 0000007515c9787c x18 000000741d05e000 x19 000000741e5a6478
x20 00000074841cfa00 x21 0000000000000001 x22 0000000000000000 x23 00000074843db380
x24 000000741e5a7020 x25 000000741e5a7020 x26 0000000000000000 x27 0000000000000001
x28 0000000000000043 x29 000000741e5a6450
sp 000000741e5a6420 lr 000000747b013f84 pc 000000747b01c378
backtrace:
#00 pc 00000000001d8378 /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 22cc95e0051ae85072c405eeeeeb312d)
#01 pc 00000000001cff80 /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 22cc95e0051ae85072c405eeeeeb312d)
#02 pc 00000000000207b0 /system/lib64/libEGL.so (android::eglSwapBuffersWithDamageKHRImpl(void*, void*, int*, int)+316) (BuildId: 248ba7f2d80e7bb9952a20e1c3493c86)
#03 pc 000000000001d0a8 /system/lib64/libEGL.so (eglSwapBuffers+80) (BuildId: 248ba7f2d80e7bb9952a20e1c3493c86)
#04 pc 00000000012ec528 /data/app/com.example.order_system-8XYsushVsEZPOltQ3k8npA==/lib/arm64/libflutter.so (BuildId: e14966237eb013b063fed6484195268f7398b594)
Lost connection to device.
Maybe it is late but it may help others. Recently I faced this error and I solved it. Your UI is rendering in Main isolate and your download events come from background isolate. Because codes in callback are run in the background isolate, so you have to handle the communication between two isolates. Usually, communication needs to take place to show download progress in the main UI. Implement the below code to handle communication:
import 'dart:isolate';
import 'dart:ui'; // You need to import these 2 libraries besides another libraries to work with this code
final ReceivePort _port = ReceivePort();
#override
void initState() {
super.initState();
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = data[1];
int progress = data[2];
setState((){ });
});
FlutterDownloader.registerCallback(downloadCallback);
}
#override
void dispose() {
IsolateNameServer.removePortNameMapping('downloader_send_port');
super.dispose();
}
static void downloadCallback(String id, DownloadTaskStatus status, int progress) {
final SendPort send = IsolateNameServer.lookupPortByName('downloader_send_port')!;
send.send([id, status, progress]);
}
void _download(String url) async {
final status = await Permission.storage.request();
if(status.isGranted) {
final externalDir = await getExternalStorageDirectory();
final id = await FlutterDownloader.enqueue(
url: url,
savedDir: externalDir!.path,
showNotification: true,
openFileFromNotification: true,
);
} else {
print('Permission Denied');
}
}
Call _download(url) function in your button and you are ready to go.
N.B: I am using sound null safety in my app and for this reason I am using null aware operator in this line of code:
final SendPort send = IsolateNameServer.lookupPortByName('downloader_send_port')!;