no print output in flutter 3.3 - flutter

Before switching to flutter 3.3 everything worked fine
The essence of the problem: When testing on the emulator, I see in the console how the prints are displayed. But, if I plug in a real device, I don't see any output. Why?
Here are my two buttons:
Container(
margin: EdgeInsets.all(50),
child: ElevatedButton(onPressed: () {
_getCurrentLocation();
print('Тык точно был!');
}, child: Text('Test'))
),
ElevatedButton(onPressed: () {print('Text tipo tyt');}, child: Text('Test2'))
and of course I don't see any console output

try log inserted of print
log('Тык точно был!');

Related

what will do after icon broke suddenly in appbar?

I am developing a flutter app where appbar icon broke suddenly without any reason. Try to fix but nothing has been found yet.
enter image description here
AppBar(
actions: [
GestureDetector(
onTap: () {},
child: SvgPicture.asset(
iconSearch,
color: VisuColors.white,
),
),
]
)
According to the image and code that you provide, things that come to my mind are:
1- Try to give width and height to SvgPicture.asset like this:
SvgPicture.asset(
iconSearch,
color: VisuColors.white,
width: 15,
height: 15,
),
2- Check the color that you gave to SvgPicture.asset, maybe it has something related to the color.
3- If these 2 solutions didn't solve your problem, check your SVG file and try to use another SVG file to see if the problem is with the file that you use. Because sometimes, the SVG files may be broken (size, color, formatting etc.).

Pie Chart disappears when "defaultRenderer: charts.ArcRendererConfig" is added to Charts in Flutter

I am completely new to Flutter, but I need to develop a mobile app for a university project using Flutter & Dart. I want to add a Pie Chart to my application and so I imported the flutter_charts package. I have gotten it to sort of work. Below is the code currently which produces a working result.
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:sa_voting_app/Charts/main_series.dart';
class VoterChart extends StatelessWidget {
const VoterChart({Key? key, required this.data}) : super(key: key);
final List<VoterSeries> data;
#override
Widget build(BuildContext context) {
List<charts.Series<VoterSeries, String>> series = [
charts.Series(
id: "Voters",
data: data,
domainFn: (VoterSeries series, _) => series.party,
measureFn: (VoterSeries series, _) => series.voters,
colorFn: (VoterSeries series, _) => series.barColor)
];
return Container(
height: MediaQuery.of(context).size.height,
padding: const EdgeInsets.all(20),
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Text(
"Current Leader Board for Parties:",
style: Theme.of(context).textTheme.bodyText1,
),
Expanded(
child: charts.PieChart(series,animate: true),
),
],
),
),
),
),
);
}
}
It produces the following output:
I want to then add labels to the PieChart. So I googled a few tutorials and came up with this code:
Expanded(
child: charts.PieChart(series,
defaultRenderer: charts.ArcRendererConfig(
customRendererId: 'mainChartRender',
arcRendererDecorators: [
charts.ArcLabelDecorator(
labelPosition: charts.ArcLabelPosition.inside),
],
),
animate: true),
),
However as soon as I add this code and try to run my application again the following happens:
As you can see the Chart dissapears, I also get an exception in the box.dart file which appears as follows:
This is the code where the exception appears:
Size get size {
assert(hasSize, 'RenderBox was not laid out: ${toString()}');
assert(() {
final Size? _size = this._size;
if (_size is _DebugSize) {
assert(_size._owner == this);
if (RenderObject.debugActiveLayout != null &&
!RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback) {
assert(
debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout ||
(RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent),
'RenderBox.size accessed beyond the scope of resize, layout, or '
'permitted parent access. RenderBox can always access its own size, '
'otherwise, the only object that is allowed to read RenderBox.size '
'is its parent, if they have said they will. It you hit this assert '
'trying to access a child\'s size, pass "parentUsesSize: true" to '
"that child's layout().",
);
}
assert(_size == this._size);
}
return true;
}());
return _size!;
}
I have tried looking at various places online to try and get a solution, but most stuff that references the "Render Box was not laid out error" is in regards to putting a ListView/GridView into a Column/Row. There was two of the following posts that reference similar issues: Flutter GoogleChart Pie chart does not render (I followed the very few solutions suggested here, but none yielded results.) There was also this post, but again its suggested solutions did not fix my issue.
Being new to Flutter I do not have any idea where to even begin troubleshooting. I would greatly appreciate it if someone could guide me in the right direction or help explain what exactly is causing the error. Thank you very much in advance for your time.
I faced similar issue as well.
I don't know why but it happens when we use defaultRenderer
After searching on google a bit I found a work around.
I don't know why it works, but it worked in my case at least.
Here is link to Source
You have to add the type parameter of the PieChart
so as you have series of type charts.Series<VoterSeries, String>> you updated code should look like
Expanded(
child: charts.PieChart<String>(series,
defaultRenderer: charts.ArcRendererConfig(
customRendererId: 'mainChartRender',
arcRendererDecorators: [
charts.ArcLabelDecorator(
labelPosition: charts.ArcLabelPosition.inside),
],
),
animate: true),
),
Notice a type parameter <String> is added in
child: charts.PieChart<String>(series,
Hope it helps.

Can't copy the file after build on flutter desktop application

in my project I can press the save button to copy a file inside flutter in debug mode and every thing works fine (the file copied), but after build and open the release application I can't copy the file with no error message, just the button pressed and nothing happened.
I tried to run the release application as administrator, but it's the same problem.
Widget buildButton() {
final isFormValid = name.isNotEmpty && path.isNotEmpty;
return Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: Colors.white,
primary: isFormValid ? null : Colors.grey.shade700,
),
onPressed: () async {
addOrUpdatePlan();
File PDF= File('assets/PDF/file.pdf');
File newPDF = await PDF.copy('$path/$name.pdf'); //////The Bug
},
child: Text(
'SAVE',
style: TextStyle(fontSize: 30),
),
),
);
}
You are using a relative path in your File constructor; that means that it will only work if the current working directory when the application is run happens to be the directory that the path is relative to. The working directory of an application is not controlled by where the application is, but how it was launched, so is not within your control as an application developer.
You should always use absolute paths, not relative paths, when writing applications. How you construct an absolute path for your use case depends on what the intended base directory is.

Is it possible to convert print data into a string in order for Firestore integration?

I would like to know whether or not it is possible to utilise the print(); command in flutter to create a String in order to link said data to a Firestore database.
I am creating a customer satisfaction application in which the customer would press a button on the screen and said button would then omit a message to the database corresponding the reaction the customer selected.
Only issue is: I have not found a way to link onPressed:in way that it can omit such data to a server or locally.
Here is a brief bit of code to somewhat witness what I am trying to achieve:
Align(alignment: Alignment.center,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: Colors.cyanAccent,
primary: Colors.deepPurple,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(55.0),
),
),
onPressed: () async {
print('Good Chosen');
print(DateTime.now());
HapticFeedback.mediumImpact();
// Close the screen and return "Good Chosen" as the result.
Navigator.pop(context, 'Good Chosen');
},
child: Image.asset('assets/good pixel.png'),
),
),
Have you considered writing the Good Chosen string directly to firestore?
Instead of / additionally to your print statements, you could write
FirebaseFirestore.instance.collection("feedback").doc()
.set({'type': 'good_chosen', 'timestamp': DateTime.now(),}, SetOptions(merge: true));

Layout bug: Not code related but design related

This time the bug i'm facing is not code related but design related. In the login page I have;
text view just saying Log In, then I have two input fields for email and password, the third widget is where the bug is. It is Forgot Password and it is constrained to the right side of the phone screen.
Now on my device, it is like "Forgot Password". But when I installed the application on another device, it went like
"Fo
rgo
t
Pa
ss
wor
d?"
Words scattered vertically.
Here are the code screenshots,
The forgot password widget, I mentioned.
then finally the button login.
I dont know whats up? Any suggestion guys?
Remove the padding and add below code
Align(
alignment: Alignment(1.2, 0),
child: FlatButton( // You can use your own widget here
child: Text(
"Forgot Password?",
style: your text style;
),
onPressed: () {},
),
),
Add maxLines: 1, to your Text Widget:
Text(
"Forgot Password?",
maxLines: 1,
),