When you "suddenly" upgraded your SDK past dart 2.12, null safety rules came into effect. Be careful when you upgrade a major version of anything (especially your SDK) because major version changes are generally breaking.
https://dart.dev/null-safety/migration-guide
You will definitely need to use null safety in the future, and migrate existing projects.
I don't think there is a quick and easy way to convert old projects. Someone can correct me if I'm wrong but if you really need it working you'll probably have to update all plugins and convert the project to null safety yourself.
There should be an easy generator you can pull your project through to convert it to null safety. But it will not fix plugins that are old and have probably changed somewhat.
You can find some stuff on YouTube too.
Actually the compiler error is pretty straightforward. You must either add "late" modifier[1] to tell the compiler that you won't access that variable before its initialization, or make the variable nullable[2].
If you're starting from scratch, flutter really "wants" you to use firebase
https://firebase.google.com/codelabs/firebase-get-to-know-flutter
I got flutter working on firebase with that tutorial with no issues at all. I've been trying and failing to get it talking to my django backend for what feels like months.
Not knowing your skill set or prior experience. This course is really good and I recommend it to everyone who wants to get started in Flutter. This is subsidized by Google, so you can get it for $10.
https://www.appbrewery.co/p/flutter-development-bootcamp-with-dart
This is a website link that is recognized as browser link only.
I guess you could try "mailto:" instead of the actual gmail website link. But this would compose a message with an empty to address.
I don't know if what I'm about to say works but you could try "https://mail.google.com/mail/u/0/#inbox". This may work.
I had a bit of programming experience prior to learning Flutter, but the course I followed assumed ZERO programming experience, and I’d definitely recommend it:
https://www.appbrewery.co/p/flutter-development-bootcamp-with-dart
Have a look here: https://dart.dev/guides/language/language-tour#instance-variables
And for late variables: https://dart.dev/guides/language/language-tour#late-variables
Especially this: "This lazy initialization is handy in a couple of cases: 1. ... 2. You’re initializing an instance variable, and its initializer needs access to 'this'."
What's your dummy data? What relation does it have to the received data? If you change your dummy data, does your received data change?
Debug this.
Use something like https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal or https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp to test your esp device without your app.
My instinct is that you're either getting something completely unrelated to your dummy data (perhaps you're reading the wrong characteristic), or you've got an endian-ness issue.
So the app enables merchants to establish online stores.A shopify of sorts.I coded up the redesigned app. I also developed the ticketing app that contains a QR code scanner. We initially used the app internally but we recently published the app on Google play store https://play.google.com/store/apps/details?id=com.hustlesasa.checkin .The mobile team consisted of two people, I and a fellow colleague
I've used Flutter Reactive BLE successfully on Android, but not with AirPods. Have you tried another device, just to see?
Since you have an Android phone, you might want to download https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en_US&gl=US
This gives you a lot of raw information on nearby bluetooth devices and lets you attempt to connect, read characteristics, etc. Make sure you can do what you want with nrf connect, then try to do it with Flutter.
You do it the same probably painstaking way as Aaron Iker did: By programming those animations. He did this with 300+ lines of CSS, you'd have to do it in Dart using AnimationController
and friends.
You could also use a tool like Rive to create animations that can then be "played" in Flutter.
You can use this package image_downloader_web
final WebImageDownloader _webImageDownloader = WebImageDownloader();
const _url = "https://picsum.photos/200";
Future<void> _downloadImage() async {
await _webImageDownloader.downloadImageFromWeb(_url);
}
…
is known as the spread operator.
From the languge tour:
> provides a concise way to insert multiple values into a collection
If you never want to have local data that isn't submitted, then you should be fine with just the firebase cache. See this: https://firebase.google.com/docs/firestore/manage-data/enable-offline
Basically, I think you optimized too early and caused yourself trouble.
You can make users to subscribe to a specific topic inside the app, then they will receive any message that has been sent to that specific topic. You can send messages directly from the app (Android only) but it is not recommended. If you don't have a dedicated backend I suggest you create a cloud function that listens a firestore collection for CRUD operations. In this case you will listen CRUD operations made on a specific collection (let's say "announcements") and send a message to the topic "announcements" after a new record has been added to the collection. At the end of the day, any user who subscribed to "announcements" topic will receive messages inside the app. See this page to explore what you can do with Cloud Functions.
This easiest way to distribute test builds for iOS is using TestFlight. Perhaps you can configure your CodeMagic setup in such a way that it will upload the app here.
If you ever want to create this "while loop" in Dart, use Generators.
https://dart.dev/guides/language/language-tour#generator
An async generator will return a stream. Listen to this stream and you'll receive a notification every time a generator generates a value.
int _value = 0;
// This is obviously bad, an useful generator would
// have a way of knowing it should stop generating values, like
// a "close" method of a class this generator is part of.
Stream<int> intGenerator() async* {
while (true) yield _value++;
}
What do you use on backend for authentication? You need a JWT or OAuth token based authentication mechanism to implement this. If you're using Firebase you can check this page for some useful information.
That's a good option.
Going off my gut here, check your progaurd rules on Android.
https://firebase.google.com/docs/database/android/start#proguard
Something just feels off with the linking of the library, but I'm not even close to sure on that.
Try taking a more traditional database approach and create collections for each of your different sub data types. Each item in those collections should have a user ID field. You'll also want to write some firestore rules to ensure only the owner can access that data, more info on that here:
https://firebase.google.com/docs/firestore/solutions/role-based-access
I'm pretty sure Firebase has some examples of firebase rules which, for example, allow your users to access their own data but no one else’s. Which you'll need if you want their app to access their own settings for example.
Edit. Here. rules
I would determine the authentication state of the current user (this.isUserLoggedIn()
) ONCE during app start, then store it somewhere you can access it. To handle authentication changes while the app is running, you could use the onAuthStateChanged handler. Now when a user wants to navigate to a protected (or public) route, you simply check the stored authentication state. No need to re-run this every time. Hope this helps - let me know if this solves your problem.
I would even consider using a subcollection for /books within the user document. That way, it is automatically clear which books each user is selling. To show all books of all users, you can use a collection group query.
For example:
/users/{userid}/books/{bookid}
In regards of grouping, you can use the seller's ID (just as u/Theprivateshow_ pointed out).
Dude... Please click the "formatting help" link, install RES, or just learn Markdown. Markdown is used on Reddit, Stack Overflow, and Github among others so it's super useful.
StreamProvider<QuerySnapshot>.value( value: DataBaseService(Provider.of<CurrentUser>(context).uid).items, child: whatever() )
Widget build(BuildContext context) {
final uid = Provider.of<CurrentUser>(context).uid.toString();
return StreamProvider<QuerySnapshot>.value(
initialData: [],
value: DataBaseService(Provider.of<CurrentUser>(context).uid).items,
child: Scaffold(
appBar: AppBar(
title: Text('Shopping app'),
backgroundColor: Color(0xff2E4C6D),
actions: [
TextButton(
onPressed: () {},
child: Text(
'Cart',
style: TextStyle(color: Colors.white, fontSize: 18),
)
)
],
),
So much easier to read. You will get much more help this way.
I've also been in same situation. I've used mac on vmware and released my app for iOS and macOS. But the system becomes too slow and you've to be very patient. In case you wonder checkout how my app came out for iOS and macOS.
Download GST Now - The simplest GST calculator app with CGST, SGST & IGST breakup!⚡
Android https://play.google.com/store/apps/details?id=com.resoso.gst_now
iOS & macOS https://apps.apple.com/us/app/gst-now-simple-gst-calculator/id1579338419
I'm building something in bubble.io at the moment.
​
Logic is moving from text.. logically. As text and syntax, whilst flexible, are slow and error prone.
100% Flutter will go LOW code, but knowing how it all works and fits together helps a LOT when doing stuff.
As a dev I'm not worried because it just allows me to do more with less, but the logic is still as hard to nut out as ever.
If you want to send notifications, when data is added, you should use Cloud functions. You can set some triggers with them. For example the 'onCreate' recognizes when new data is added or 'onUpdate' when data is updated.
These functions can then send a Notification to your phone
That's something he'd need to integrate in php.
So when he writes an entry to the DB he can fire off a notification.
You should be creating the snapshot with a "where" query before passing it to your app. Essentially check for it as a field in the document.
The other option could be to struture your data such that all docs for one user are under a single collection of docs and subcollections, in that case you make the folder path their uid. This may be better for data that is very compartmentalized and not shared.
I prefer the first option as my app shares data. See the link.
https://firebase.google.com/docs/firestore/query-data/queries
I tried the link and I am still getting the same problem.
Also, what was interesting was when i used the link :
https://mail.google.com/mail/u/0/#search/this+is+a+search
it just went to the browser and the regular inbox, not a search. However if you paste this link in your browser, it will bring you to the search.
I mean Uncle Bob Clean Architecture. To be more precise, Resocoder implementation of Clean Architecture.
If you have a domain attached, even a ddns, you can use certbot. It's easy to setup and you can add autorenew to the certificate.
I don't think that Google or Apple will reject your app for not having https but today there's no reason not to use https.
One has already suggested this course Angela Yu's "Introduction to Flutter" (https://www.appbrewery.co/p/intro-to-flutter). Angela is a great teacher, discusses basics of Dart Programming, as she takes you through different practical and fun programming projects. As a bonus, Angela has a very attractive voice. There's a reason, it is called the best Flutter course available online.
I’m still learning it myself. I’m almost finished with this course which I highly recommend and gets into Firebase in the last couple projects: https://www.appbrewery.co/p/flutter-development-bootcamp-with-dart
And after that I’m planning on taking Fireship’s course: https://fireship.io/courses/flutter-firebase/
Thanks for the code example. In your class Quiz
you have the field questionIndex
. As you marked this variable as a final it can't be change after you gave it a value and that's why you can't use it into constructor. For be able using it into class constructor you can assign it there with some default value like it:
class Quiz extends StatelessWidget {
final int questionIndex;
Quiz({
this.questionIndex = 0,
});
And the second one that I can see you trying to assign value of type int
to the type Function
here:
final Function() answerQuestion = 0;
You can't do this because they have the different types. You can only assign int = int
or Function = Function
. Try to just delete = 0;
.
And by the way what code editor do you use? Because it seems like you don't have dart analayzer there. Maybe this article will be helpful https://dart.dev/guides/language/sound-problems.
Did you take a look at this?
Basically you’re trying to assign null to a value that’s is not nullable.
You only need to write required this.someVariable
without the @.
Prefer is not an error. This is called linting. If you look in your pubspec.yaml file, you probably have this included:
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
What it is saying is, use const
when possible. Presumably you don't know the difference yet between const
, late
, static
, final
, var
and how they interact with each other. This is a pretty large subject so I'll just link you the language tour. Don't expect to understand it all right away, it's a lot of new words. Maybe to start, scope down your reading to what "compile time constant" means.
I would not have been able to Google that myself although I went through most of Packt Flutter Cookbook, dart.dev tutorials and some other cookbooks and tutorials on flutter.dev, terminology seems to be the key in successful searches.
If you know you will only listen to a Stream once during the entire lifetime of that Stream, then you can use an ordinary Stream.
If you will listen to it repeatedly, or by different listeners at the same time, you need to make the stream into a Broadcast Stream.
https://dart.dev/tutorials/language/streams#two-kinds-of-streams
Hey! Sorry to bother you again. I followed all of the steps and made sure my google-services.json was in the app folder but for some reason, the app is crashing on startup. Would you happen to know what this error message means?
---------------------------------------------------------------------------------------------------------------------------------
Running Gradle task 'assembleDebug'...
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:firebase_core
- package:firebase_core_platform_interface
- package:quiver
- package:plugin_platform_interface
For solutions, see https://dart.dev/go/unsound-null-safety
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 22s
Exception: Gradle task assembleDebug failed with exit code 1
---------------------------------------------------------------------------------------------------------------------------------
Look at this: https://dart.dev/codelabs/dart-cheatsheet String Interpolation To put the value of an expression inside a string, use ${expression}. If the expression is an identifier, you can omit the {}.
The term identifier refers to a variable that is not a property of an object. For example, a local integer variable (final int i = 10) would '$i'. If you were referencing an object like a variable passed to the constructor (final String bio) of a stateful widget within its state object, you would use '${widget.bio}'.
You could also combine it with other strings. For example, looking at the integer example, if you wanted the resulting string to be object.10, you could use 'object.$i'. You could also concatenate the contents of the widget.bio as well by using 'object.${widget.bio}'. I hope that helps.
You’re correct. However, it’s normal to not put everything into just one .dart file, but to use several files arranged into a directory structure.
If you haven’t seen it before, here are the standard conventions for file system layout
Given your experience you shouldn't have any trouble learning the Dart language you need to be a Flutter developer. Reading through the Dart Language Tour should get you up to speed.
The Dart file is formatted in a highly opinionated way according to the rules of https://dart.dev/guides/language/effective-dart. This is implemented in dartfmt
(which soon becomes dart format
). You are advised to accept the standard way of formatting so that the formatting doesn't change between commits in shared code.
Imports are either package specific or by relative path. Since your code is most likely in lib, you do not need to include lib in your import statement unless it is in a sub-folder called lib from the location of the dart file you are editing.
>query?.toLowerCase()
Query is probably null.
it's probably.contains(null);
Honestly, just put a breakpoint in the debugger and figure out what data is null, and avoid it. Use default values instead of null, and don't assign null anywhere, instead of null, use "" blank strings.
Or use a newer build of dart and use compile time null safety
https://dart.dev/null-safety
The method 'setState' isn't defined for the type 'Auth'.
Try correcting the name to the name of an existing method, or defining a method named 'setState'.dartundefined_method
I got this error instead. Do I need to write the setstate function on my own or is there any library that I can import from. Really appreciate your help!
I did something similar to your first problem, I had a situation whereby I needed to get constant update from device battery which is a future similar to what APIs returns, so I converted the battery api to a stream and the received new update every 5 seconds, which in your case is 1 minute, you could check this link to get details on how to achieve that https://dart.dev/tutorials/language/streams. Once you have gotten the stream, you could hook it up with stream provider and voila.
I believe I just copied from the firebase_admob package site.
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'], contentUrl: 'https://flutter.io', birthday: DateTime.now(), childDirected: false, designedForFamilies: false, gender: MobileAdGender.male, // or MobileAdGender.female, MobileAdGender.unknown testDevices: <String>[], // Android emulators are considered test devices );
I'm currently still on bed, but I can check the exact targeting info later
I was super excited and I researched (as I didn't know MS even had an emulator, but it makes sense) and found this. When I installed it against the advice on top, I found the latest Android image is 6.0.....
Could it be something like sendgrid to a google cloud function to a Firebase message/notification.
https://sendgrid.com/docs/for-developers/parsing-email/setting-up-the-inbound-parse-webhook/
I have not done it, but it makes logical sense. You would need to provide a good way to verify the user account especially if it is being used for OTP.
Take a look at this
That's just a very simple example.
If you want to start a new form page to perform operations on the list remember that the state yielded must be different from the current state, otherwise bloc builder will not rebuild the widget.
A more sophisticated solution can be use a bloc to emit the list state and another bloc to perform actions on the list, by this way you don't have to deal with states overlap (for example you perform an insert action, you yield an error state but when you return on the previous page you have lost the loaded state and so the list).
But for now stay simple and try to understand how the Bloc pattern and its components works firstly. At the bottom of the pub.dev package page there are a lot of different examples.
When you feel confident with the basics you could check ResoCoder "Flutter Firebase & DDD course" for a more advanced approach.