Using Flutter and Firebase dynamic links, I am able to create a link. When it is clicked it opens the app but there is no link data, and no callbacks that a link was clicked is fired. Instead in the Xcode logs I get Deep Link Web URL query is empty Link is copied from the app into Notes, then clicked. Is there anything that I am missing, or what else can I check to get this working?
Firebase Deep Link Web URL query is empty - iOS
Checked this relevant post, but installing the required pod dependencies is not the solution as you can see below in the pod install logs.
Flutter Doctor
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15 19A582a, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed
instructions.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.5)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.4)
[!] IntelliJ IDEA Community Edition (version 2019.1.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
Xcode logs
---- Firebase Dynamic Links diagnostic output start ----
Firebase Dynamic Links framework version 4.0.7
System information: OS iOS, OS version 13.3.1, model iPhone
Current date 2020-03-10 12:46:34 +0000
Device locale en-US (raw en_US), timezone America/Boise
Specified custom URL scheme is com.pitch.links and Info.plist contains such scheme in CFBundleURLTypes key.
AppID Prefix: XXXXXXXXXX, Team ID: XXXXXXXXXX, AppId Prefix equal to Team ID: YES
performDiagnostic completed successfully! No errors found.
---- Firebase Dynamic Links diagnostic output end ----
Runner[366:14705] 6.18.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
Runner[366:14754] 6.18.0 - [Firebase/Analytics][I-ACS800003] Registered an SDK that has already registered. Default flags will be overwritten. SDK name: app_measurement
Runner[366:14754] 6.18.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
Runner[366:14712] Connection 3: received failure notification
Runner[366:14712] Connection 3: failed to connect 12:8, reason -1
Runner[366:14712] Connection 3: encountered error(12:8)
Runner[366:14712] Task <03A1535D-FD13-4872-B14B-6673E202F028>.<2> HTTP load failed, 0/0 bytes (error code: -1003 [12:8])
Runner[366:14712] Task <03A1535D-FD13-4872-B14B-6673E202F028>.<2> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x282e21b30 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, NSErrorFailingURLStringKey=https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key= AIzaxxxxxxx_xxxxxxxxxx_xxxxxxxxxxxxxxxx, NSErrorFailingURLKey=https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key= AIzaxxxxxxx_xxxxxxxxxx_xxxxxxxxxxxxxxxx, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}
Runner[366:14505] [ProcessSuspension] 0x10e4e13b0 - ProcessAssertion::processAssertionWasInvalidated()
Runner[366:14505] [ProcessSuspension] 0x10e4e1410 - ProcessAssertion::processAssertionWasInvalidated()
Runner[366:14707] 6.18.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
Runner[366:14707] 6.18.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
dismiss = 1;
"is_weak_match" = 1;
}
Runner[366:14505] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
Runner[366:14505] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
Runner[366:14505] Returning local object of class NSString
Runner[366:14505] Can't end BackgroundTask: no background task exists with identifier 14 (0xe), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Runner[366:15138] 6.18.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty
apple-app-site-association
{"applinks":{"apps":[],"details":[{"appID":"XXXXXXXXXX.com.pitch.links","paths":["NOT /_/*","/*"]}]}}
applinks:pitchlink.page.link is listed as an Associated Domain
and URL Type with Identifier of Bundle ID and URL Schemes com.pitch.links has been added to the Info.plist
Flutter main.dart
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dynamic Links',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Dynamic Links'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Uri dynamicUrl;
#override
void initState() {
super.initState();
this.initDynamicLinks();
}
void initDynamicLinks() async {
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://pitchlink.page.link',
link: Uri.parse('https://example.com/suffix?d=1'),
iosParameters: IosParameters(
bundleId: 'com.pitch.links',
minimumVersion: '0.0.1',
),
);
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink?.link;
print(deepLink.toString());
}, onError: (OnLinkErrorException e) async {
print('onLinkError');
print(e.message);
});
ShortDynamicLink link = await parameters.buildShortLink();
setState(() {
dynamicUrl = link.shortUrl;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Dynamic Link:',
),
dynamicUrl != null
? SelectableText(
dynamicUrl.toString(),
)
: Container(),
],
),
),
);
}
}
pubspec.yaml
name: pitch_links
description: A new Flutter project.
version: 0.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_dynamic_links: ^0.5.0+11
firebase_analytics: ^5.0.11
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
pod install --clean-install --verbose
-> Using Firebase (6.18.0)
-> Using FirebaseAnalytics (6.3.0)
-> Using FirebaseAnalyticsInterop (1.5.0)
-> Using FirebaseCore (6.6.3)
-> Using FirebaseCoreDiagnostics (1.2.1)
-> Using FirebaseCoreDiagnosticsInterop (1.2.0)
-> Using FirebaseDynamicLinks (4.0.7)
-> Using FirebaseInstallations (1.1.0)
-> Using Flutter (1.0.0)
-> Using GoogleAppMeasurement (6.3.0)
-> Using GoogleDataTransport (4.0.1)
-> Using GoogleDataTransportCCTSupport (1.4.1)
-> Using GoogleUtilities (6.5.1)
-> Using PromisesObjC (1.2.8)
-> Using firebase_analytics (0.0.1)
-> Using firebase_dynamic_links (0.1.0)
-> Using nanopb (0.3.9011)
The solution that worked to fix my issue was to call await FirebaseDynamicLinks.instance.getInitialLink(); within initDynamicLinks() The same errors still appear in the Xcode logs, but I am able to parse out the link data.
Related
I am using webview_flutter 3.0.4 to load a login web page in iOS I have tried both on simulator and on device the app loading it shows the webpage login page for a few milisecounds and then crashs and I get this error
WKErrorDomain WebResourceErrorType.webContentProcessTerminated
I am using Webpage url that use OAuth 2.0 to generate a unique login challenge everytime.
Flutter doctor -v output :
`
[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-x64, locale en-US)
• Flutter version 3.3.9 on channel stable at /Users/test/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b8f7f1f986 (6 days 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
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[✓] VS Code (version 1.63.2)
• VS Code at /Users/test/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.36.0
[✓] Connected device (1 available)
• macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64
[✓] HTTP Host Availability
Code Of WebView :
WebView(
onWebResourceError: (error){
print(error.domain);
print(error.errorType);
print(error.failingUrl);
},
zoomEnabled: false,
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
navigationDelegate: (NavigationRequest request) async {
if (request.url.contains(“authenticated?redirect”)) {
await unsubFromOldFCMtopics(“From LOgin”);
//You can do anything
Navigator.push(
context,
MaterialPageRoute(
builder: (c) => MainScreen(),
settings: RouteSettings(name: “main-screen”)));
//Prevent that url works
return NavigationDecision.prevent;
}
//Any other url works
return NavigationDecision.navigate;
},
onPageStarted: (urli) {
print(urli);
},
onPageFinished: (_) async {
print(_);
final gotCookies = await cookieManager.getCookies(url);
if (gotCookies.isNotEmpty) {
Provider.of<AppData>(context, listen: false)
.updateCookies(gotCookies[0].value.toString());
}
},
onWebViewCreated: (WebViewController webViewController) {
_Webcontroller = webViewController;
if (_controller.isCompleted == false) {
_controller.complete(webViewController);
}
},
)
`
Also the webpage loads fine when i disable the JavascriptMode but then no buttons on the webpage work.
This issue is related to WKWebView after updating to iOS 16.1.1
I have managed to get the native Swift code that can be used to recreate this issue.
Just create a native ios project in XCode but do not use SwiftUI as the UI framework and replace the content of the ViewController.swift file with the code below.
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView: WKWebView!
private func createWebView() {
let preferences = WKWebpagePreferences()
preferences.allowsContentJavaScript = true
let configuration = WKWebViewConfiguration()
configuration.defaultWebpagePreferences = preferences
webView = WKWebView(frame: view.bounds, configuration: configuration)
webView.navigationDelegate = self
view.addSubview(webView)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
createWebView()
let url = URL(string: url)!
webView.load(URLRequest(url: url))
webView.allowsBackForwardNavigationGestures = true
}
}
In the process of developing iOS application with Flutter, there is a problem that HTTP response cannot be decoded with UTF-8, and I would like to solve it.
The Android Pixel 2 emulator was able to decode without any problems, so I think it is an iOS-specific problem.
The result is the result of running using tPhone 12 Pro Max emulator. (iOS Deployment Target=9.0)
This issue is that content of decoded_body_byte is null.
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:html/dom.dart' as dom;
import 'package:http/http.dart' as http;
import 'package:charset_converter/charset_converter.dart';
import 'package:flutter_user_agent/flutter_user_agent.dart';
// skip
String userAgent;
try {
userAgent = await FlutterUserAgent.getPropertyAsync('userAgent');
print("userAgent: ${userAgent}");
} on PlatformException {
userAgent = '<error>';
}
var response = await http.Client().get(Uri.parse("http://news4vip.livedoor.biz/archives/52385788.html"), headers: {'User-Agent': userAgent});
print("Response status: ${response.statusCode}");
print("response.headers: ${response.headers['content-type']}");
String decoded_body_byte = await CharsetConverter.decode("UTF-8", response.bodyBytes);
print("decoded_body_byte: ${decoded_body_byte}"); // ここの結果がnullになってしまうことが問題になっています。
Uint8List encoded = await CharsetConverter.encode("UTF-8", "【画像】中日「かっこいい」今季のユニホーム発表www");
print("encoded.length: ${encoded.length}");
String decoded_body_byte_only_title = await CharsetConverter.decode("UTF-8", response.bodyBytes.sublist(71, 71 + 78));
print("decoded_body_byte_only_title: ${decoded_body_byte_only_title}");
The following is the output result of the above code.
2021-01-23 17:09:29.964984+0900 Runner[89036:14458916] flutter: userAgent: CFNetwork/1209 Darwin/20.2.0 (iPhone iOS/14.3)
2021-01-23 17:09:30.187131+0900 Runner[89036:14458916] flutter: Response status: 200
2021-01-23 17:09:30.190547+0900 Runner[89036:14458916] flutter: response.headers: text/html; charset=utf-8
2021-01-23 17:09:30.195755+0900 Runner[89036:14458916] flutter: decoded_body_byte: null
2021-01-23 17:09:30.197368+0900 Runner[89036:14458916] flutter: encoded.length: 78
2021-01-23 17:09:30.198128+0900 Runner[89036:14458916] flutter: decoded_body_byte_only_title: 【画像】中日「かっこいい」今季のユニホーム発表www
Below is the output result of $ flutter doctor.
I would appreciate it if you could answer.
% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[!] Android Studio (version 4.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.52.1)
[✓] Connected device (2 available)
! Doctor found issues in 2 categories.
I can decode target web page using below Plugin instead of charset converter.
Maybe this http response included illegal character.
https://api.flutter.dev/flutter/dart-convert/Utf8Codec/decode.html
final decoded = Utf8Decoder(allowMalformed: true).convert(response.bodyBytes);
i have flutter app setup with firestore, fcm and firebase cloud storge which works great on android, and on ios i have added GoogleService-Info.plist to Runner from xcode and also called await Firebase.initializeApp(); on my main.dart on android firestore and storage works good i am able to CRUD data, upload files but when i try to upload media on to firebase on
ios with this code
Future uploadFile(int index, int type) async {
String fileName =
DateTime.now().millisecondsSinceEpoch.toString() + "${widget.userId}";
StorageReference reference = FirebaseStorage.instance.ref().child(fileName);
StorageUploadTask uploadTask = reference.putFile(File(images[index]));
StorageTaskSnapshot storageTaskSnapshot = await uploadTask.onComplete;
storageTaskSnapshot.ref.getDownloadURL().then((downloadUrl) {
setState(() {
isLoading = false;
imageUrl = downloadUrl;
});
}, onError: (err) {
setState(() {
isLoading = false;
});
});
}
the ios app crashes abnormally nothing is being printed on the console when run normally
but when run on verbose mode i see this logged
[+123976 ms] Service protocol connection closed.
[ +1 ms] Lost connection to device.
[ +35 ms] DevFS: Deleting filesystem on the device
(file:///Users/Me/Library/Developer/CoreSimulator/Devices/12E19722-CC83-452B-B263-EF624D069BED/dat
a/Containers/Data/Application/BC48EA57-B913-4281-9628-59C783B0FE77/tmp/r2a_mobile28vRsI/r2a_mobile/)
[ +258 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not
completed
[ +4 ms] "flutter run" took 223,298ms.
[ +271 ms] ensureAnalyticsSent: 264ms
[ +2 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ +7 ms] Shutdown hooks complete
[ +2 ms] exiting with code 0
have also added <key>CFBundleURLSchemes</key> on to my info.plist with my REVERSED_CLIENT_ID from google plist
Firebase Packages on pubspec:
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2
firebase_storage: ^4.0.0
firebase_messaging: ^7.0.0
Flutter Version:
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bbfbf1770c (10 days ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1
i really need some help here
Thanks in Advance
I'm experiencing some odd behavior where a Provider behaves differently in debug vs. release mode.
This question is posted in off this question.
Here is a short description of the functionality: I have a list of ExpansionTiles (containing TextFormFields in their body) and a FloatingActionButton that adds to the list of ExpansionTiles. Below those two widgets I have one Back button and one Next button. The Next button needs be "unavailable" (ie. throw an error message to the user and have the color grey) as long as any TextFormField in the list of ExpansionTiles is incomplete. Once all TextFormFields are ready the Next button should change color and direct the user to a new page. Changing the color and functionality works fine in debug, but not in release mode (ie. after running: flutter build web).
Firstly: TravelProceedModel monitors the status of whether the user can click the Next button or not. Ie. this is just a simple bool. Whenever updateCanProceed() is called I update canProceed and also notifyListeners().
import 'package:flutter/material.dart';
class TravelProceedModel extends ChangeNotifier {
bool canProceed;
void updateCanProceed(bool value) {
canProceed = value;
notifyListeners();
}
}
Secondly, the TravelProceedModel is implemented using the ChangeNotifierProvider and then using Consumer. I'm expecting (and this works in debug) that when canProceed is changed this line: "nextEnabled: proceedModel.canProceed" should cause the button the change color. However, this only works in debug mode.
class TravelDeductionTrips extends StatefulWidget {
#override
_TravelDeductionTripsState createState() => _TravelDeductionTripsState();
}
class _TravelDeductionTripsState extends State<TravelDeductionTrips> {
#override
Widget build(BuildContext context) {
String year = Provider.of<UserSelectionsModel>.(context).selected_report["year"];
String report = Provider.of<UserSelectionsModel>(context).selected_report["report"];
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => TravelProceedModel()
),
ChangeNotifierProvider(
create: (context) => TravelModel(
year: year,
report: report,
),
),
],
child: Consumer<TravelModel>(
builder: (context, travelModel, child) {
return FutureBuilder(
future: travelModel.fetchTripsToLocalSession(),
builder: (context, data) {
if (data.connectionState == ConnectionState.done) {
return Column(
children: <Widget>[
TravelDeductionTripList(),
Consumer<TravelProceedModel>(
builder: (context, proceedModel, child) {
proceedModel.updateCanProceed(
travelModel.checkProceedCondition()
);
return BackNextButtons(
backEnabled: true,
nextEnabled: proceedModel.canProceed,
backText: "Tilbage",
nextText: travelModel.trips["next_action_title"],
errorMessage: travelModel.proceedErrorMessage,
nextFunction: () async {
await addQuestionIDtoStack(year, report, travelModel.trips["next_question_id"], true);
}, // No special function is needed, this is just a simple next
);
},
),
],
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}
);
}
),
);
}
}
NB! proceedModel.canProceed is updated from within TravelDeductionTripList() which calls
Provider.of<TravelProceedModel>(context, listen: false).updateCanProceed(
Provider.of<TravelModel>(context, listen: false).checkProceedCondition()
);
The Next button only changes colors after reloading the widget. Ie. it appears that the TravelProceedModel is being updated but that the widget is not being redrawn in the UI - although it happens perfectly in debug mode.
Does anybody have any idea why debug works but release does not?
Below is my "flutter doctor -v". Notice, that this is a flutter web project.
[✓] Flutter (Channel beta, v1.15.17, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.15.17 at /Users/danni/Documents/flutter/flutter
• Framework revision 2294d75bfa (13 days ago), 2020-03-07 00:28:38 +0900
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/danni/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used
to invoke it.
This can usually be fixed by re-installing CocoaPods. For more info, see
https://github.com/flutter/flutter/issues/14293.
To re-install CocoaPods, run:
sudo gem install cocoapods
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.43.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[✓] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.149
• Web Server • web-server • web-javascript • Flutter Tools
! Doctor found issues in 1 category.
I had the same problem, and I've made a workaround for it.
Since listen is a parameter, you can pass any other bool variable to it (should not be a constant true or false).
There is a built-in bool variable in foundation.dart package called kReleaseMode.
So here is an example, how i handled this listener problem between debug and release mode:
await Provider.of<AuthService>(context, listen: kReleaseMode).loginUser(
user: _username, password: _password);
For me, it works perfectly.
I'm studying clipping image as curve, but CustomClipper is not working suddenly.
Only clipper property of IreneClipper not works. How can I fix it?
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Clock',
theme: ThemeData(
primarySwatch: Colors.blue
),
home: IreneClip(),
);
}
}
class IreneClip extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(backgroundColor: Colors.orange,),
body: ClipPath(
child: Image.asset('assets/irene.jpg'),
clipper: IreneClipper(),
),
);
}
}
class IreneClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
Path path = Path();
path.moveTo(0.0, size.height);
return Path();
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
}
}
Error message
I/flutter (25014): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY
╞═════════════════════════════════════════════════════════ I/flutter
(25014): The following assertion was thrown during performLayout():
I/flutter (25014): The _ScaffoldLayout custom multichild layout
delegate forgot to lay out the following child: I/flutter (25014):
_ScaffoldSlot.body: RenderClipPath#ab20f NEEDS-LAYOUT NEEDS-PAINT I/flutter (25014): Each child must be laid out exactly once. I/flutter
(25014): I/flutter (25014): When the exception was thrown, this was
the stack: I/flutter (25014): #0
MultiChildLayoutDelegate._callPerformLayout.
(package:flutter/src/rendering/custom_layout.dart:222:13) I/flutter
(25014): #1 MultiChildLayoutDelegate._callPerformLayout
(package:flutter/src/rendering/custom_layout.dart:230:8)
Flutter doctor
[√] Flutter (Channel beta, v1.0.0, on Microsoft Windows [Version 10.0.17134.472], locale ko-KR)
• Flutter version 1.0.0 at C:\flutter
• Framework revision 5391447fae (5 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\AndroidSDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\AndroidSDK
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[√] Android Studio (version 3.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 31.3.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[!] IntelliJ IDEA Community Edition (version 2018.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] VS Code, 64-bit edition (version 1.30.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
I solved, shouldReclip method must return true if you want to hot reload clipping image.
class IreneClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height-40);
path.lineTo(size.width, size.height-60);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}
You need to wrap it with like:
Column(
children: [
SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
Stack(
clipBehavior: Clip.none,
children: <Widget>[
// stack overlaps widgets
ClipPath(
clipper: YOURCUSTOMCLIPPER(),
child: Container(
width: MediaQuery.of(context).size.width,
height: 140,
color: Colors.red,
),
),
],
),
],
),
),
),
],
),