Flutter Error: No named parameter with the name 'displayLarge' - android

I am working on an app, I posted last update on git 2 days ago and haven't touched the code since. Now, I opened android studio and it was giving me this error when I tried to run it... I tried deleting repository from my computer and then cloning it again but it didn't work. I have also tried searching for similar problems, and found out there was a similar problem with speed-dial package and one comment said something about broken package versions. Anyways, this is the error I am getting after I try running my app:
These are first few lines of the error it's giving me, but there is more than a thousand lines following these.
I also tried running flutter doctor and it gave me the following:

google_fonts: ^2.3.1 has also solved the problems left in google_fonts: 2.3.0
Well! This issue will be raised in all projects using the google_fonts with a caret sign (^).
The caret sign (^) is used for pub dependencies in Dart to indicate a range of version numbers that are allowed. Specifically, any version from the specified version up to (but not including) the next non-breaking version is ok.
So google_fonts: ^2.2.0 is the same as '>=2.2.0 <3.0.0', It's shorthand for the longer form. The ^ is saying, I want to automatically use the most up-to-date package from Pub as long as that update won't break anything in my app. The google_fonts: 2.3.0 has some issues with this as of now.
Solution Steps :
Remove (^) from your current google_fonts. max can be set as google_fonts: 2.2.0.
To make sure, this does not conflict with any other dependency, for once do 'pub get'.
Try to invalidate caches and restart. This should clean error, else do flutter clean to remove old updated google_fonts and pub get.
Done! You are good to go. Happy Codding!!!

Please follow the below steps to solve the issue.
Open pubspec.yaml file.
Change google_fonts: ^2.2.0 to google_fonts: 2.2.0
Save.

Well, I don't know if you have tried this, but this problem is described here: issue 219
In summary, you have to use google_fonts v2.3 for Flutter v2.1 or greater.

set the package version to google_fonts: 2.2.0 and it should work properly

as they said, just remove the ^ from the google fonts on the dependencies on the pubspec.yaml
(google_fonts: ^2.3.1 to google_fonts: 2.3.1)
then flutter clean && pub get.

I had the same problem but it was not an issue with dependencies as for others. I stopped getting this error when I put "shape" in the scope of styles.
Example with my problem:
ElevatedButton(
child: Text('Sign in with Google'),
onPressed: _signInWithGoogle,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
Example when "shape" stopped giving an error:
ElevatedButton(
child: Text('Sign in with Google'),
onPressed: _signInWithGoogle,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
),

Related

Tapping Flutter Textfield Crashes the app

here's a video which shows my problem.
https://drive.google.com/file/d/1YTnu1amCYhN9CGLygAyag-LhYMn3BDiO/view?usp=sharing
Thing is, I'm developing an app in flutter and have been debugging it for several months already in a real hardware (my own phone with android 11). Suddenly, today I have experienced this error. When I tap on a textfield or textformfield, the app crushes and restarts automatically. I've researched a couple forums which suggest:
But it doesn't work for me.
I've already been several hours trying to figure this out, rebooting my pc, my phone, trying an emulator, a friend's phone instead of mine, changing the properties of the textfields... But nothing seems to work. I've read that this problem happens randomly at some android 11 devices, but have seen no solution to it (I don't even know if there exists one).
About my code, it's as simple as this:
Flexible(
child: FractionallySizedBox(
widthFactor: 0.75,
heightFactor: 0.75,
alignment: Alignment.centerLeft,
child: TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.person),
fillColor: Colors.white.withOpacity(0.80),
filled: true,
),
onChanged: (String v) => nombre = v,
textInputAction: TextInputAction.go,
),
),
),
My pubspec dependencies are:
firebase_core: ^1.17.1
firebase_auth: ^3.3.19
firebase_database: ^9.0.15
firebase_messaging: ^11.4.1
firebase_storage: ^10.2.17
event: ^2.0.5
mutex: ^3.0.0
chat_bubbles: ^1.3.0
clipboard: ^0.1.3
image_picker: ^0.8.5+3
shared_preferences: ^2.0.15
path_provider: ^2.0.11
xdg_directories: ^0.2.0
flutter_tts: ^3.4.0
google_speech: ^2.1.1
speech_to_text: ^5.6.0
record: ^4.1.1
gcloud: ^0.8.5
flutter_local_notifications: ^9.6.0
http: ^0.13.4
crypto: ^3.0.2
semaphore: ^0.2.1
audioplayers: ^1.0.0
spring_button: ^2.0.0
google_fonts: ^3.0.1
flutter_app_name: ^0.1.1
As I said, it has delivered no problems for the last months.
If anyone has an idea that may make it work again, I would be very grateful. And if want more data of my project, just ask for it. Thank you very much in advance.
Three weeks since this problem appeared, I have at last discovered where the error was all along. It seems I had a window in the Navigator pile that was a Stateless Widget instead of a Stateful Widget, and when that happens, every time a reload happens (hot reload, textfield tapping, launching the keyboard, etc), provokes that the application restarts. It seems logical, actually, but I didn't think about that window at all, so I just popped it from the Navigator as soon as I finished with it and everything went just fine.

Trouble using the audioplayers package in my flutter app

I started with flutter last week and I got this problem with the audioplayer package. I am doing a Flutter Development Bootcamp with Dart at Udemy. I followed almost everything at the video, but I recived a huge error message that I can't solve.
This is my code:
import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
void main() => runApp(XylophoneApp());
class XylophoneApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.lightBlue,
body: SafeArea(
child: Container(
child: Center(
child: TextButton(
onPressed: (){
final player = AudioCache();
player.play('assets/note1');
},
child: Text(
'click me'
),
),
),
),
),
),
);
}
}
This is the error message that i get:
Running Gradle task 'assembleDebug'...
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/victo/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15... (The message is much more larger than this)
What went wrong:
Execution failed for task ':audioplayers:compileDebugKotlin'.
Compilation error. See log for more details
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 21s
Exception: Gradle task assembleDebug failed with exit code 1
I've seen this message The binary version of its metadata is 1.5.1, expected version is 1.1.15, but I dont know what to do with it or how I can solve it.
This is my pubspec.yaml:
name: xylophone
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
audioplayers: ^0.19.1
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/
In gradle files, go to build.gradle (Project: YourApp). Then, change the following code (in buildscript):
from
ext.kotlin_version = '1.3.50'
to
ext.kotlin_version = '1.4.32'
or what ever the latest version of Kotlin available and make sure to update Kotlin version on Android Studio as well
After following the instructions, your error will be resolved.
You can look into error log Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15 but try to 1.3.50, i have app with audioplayer i am using this version if it doesn't work use 1.1.15 or the suggested version after changing version uninstall app and run flutter clean and run again
Try downgrade to a lower kotlin version in build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
}
Also refer this answers also if doesn't work in case
Migration Guide
dependencies:
audioplayers: ^0.x.x
to
dependencies:
audioplayers: ^1.0.1
https://github.com/bluefireteam/audioplayers/blob/main/migration_guide.md
try with this
AudioCache is dead, long live Sources
One of the main changes was my desire to "kill" the AudioCache API due to the vast confusion that it caused with users (despite our best efforts documenting everything).
We still have the AudioCache class but its APIs are exclusively dedicated to transforming asset files into local files, cache them, and provide the path. It however doesn't normally need be used by end users because the AudioPlayer itself is now capable of playing audio from any Source.
What is a Source? It's a sealed class that can be one of:
UrlSource: get the audio from a remote URL from the Internet
DeviceFileSource: access a file in the user's device, probably selected by a file picker
AssetSource: play an asset bundled with your app, normally within the assets directory
BytesSource (only some platforms): pass in the bytes of your audio directly (read it from anywhere).
If you use AssetSource, the AudioPlayer will use its instance of AudioCache (which defaults to the global cache if unchanged) automatically. This unifies all playing APIs under AudioPlayer and entirely removes the AudioCache detail for most users.
If you are using the latest version of audioplayers in my case ^1.0.1 then your code should look like this instead
onPressed: () async {
final player = AudioPlayer();
await player.play(AssetSource('note1.wav'));
},
Wishing you all the best in your learning

Flutter CachedNetworkImage doesn't work for App downloaded from playstore, stuck on placeholder

I'm using CachedNetworkImage in my app and it works fine when I run it in debug or release on Android, however when I upload the aab to the Play Store and download the app from the Play Store, the image is just stuck on the placeholder.
Here's how I'm using it in the app. Note that I use a Text widget for the placeholder and the error so that I can visually debug any issues on the release version:
child: Stack(
children: <Widget>[
url != null
? CachedNetworkImage(
imageUrl: url,
errorWidget: (context, url, error) => Text("$error"),
placeholder: (context, url) => Text("Loading $url"),
imageBuilder: (context, imageProvider) => Container(
width: double.infinity,
height: 150,
decoration: BoxDecoration(
image: DecorationImage(image: imageProvider, fit: BoxFit.fitWidth),
),
),
)
: Container(),
It just stays on the placeholder and looks like this
I'm using the latest version of cached_network_image in the pubspec:
cached_network_image: ^2.4.1
Here's what I've tried so far to help narrow down the problem:
Using Image.network(url) instead of CachedNetworkImage. The images load fine when I do this, so I know it's not a problem with the internet or the url.
Running a release build on the device using flutter run --release. This works fine, the images load correctly.
Trying out multiple devices. I tried using a Samsung Galaxy 8 on Android 8 and a Pixel 2xl on Android 11. Both work fine with debug builds and release builds, but not when downloaded from the Play Store.
Making sure the URL is publicly accessible and that internet permissions are enabled. The app is able to load other content from the internet fine and the image url is on a public domain.
I ended up finding the solution in the github issues here github.com/Baseflow/flutter_cached_network_image/issues/497. Turns out it is a proguard issue with the sqflite library that CachedNetworkImage uses. The solution, until they fix it in the library, is to add a the default proguard file to the build.gradle file:
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true // Add these lines
shrinkResources true // Add these lines
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') // Add these lines
}
}
I'm actually really surprised no one else has posted about this on SO that I could find, seems like a major breaking change to the library.

Error: Not found: 'dart:js' import 'dart:js';

I am creating a PopupMenuButton() in the AppBar section.
This is my file:
import 'dart:js';
import 'package:bfdi_app/settings.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class ProfilePage extends StatefulWidget {
#override
_ProfilePageState createState() => _ProfilePageState();
}
class _ProfilePageState extends State<ProfilePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'App_Name',
),
actions: <Widget>[
PopupMenuButton(
icon: Icon(Icons.settings),
onSelected:(value){
if(value==0){
Navigator.push(
context,
MaterialPageRoute(builder: (context)=>SettingPage())
);
}
},
itemBuilder: (context) => [
PopupMenuItem(
child: Text("Settings"),
value:0,
],
),
],
),
}
Now I am facing an error in Console Log:
Compiler message:
lib/Pages/addPost.dart:1:8: Error: Not found: 'dart:js'
import 'dart:js';
^
lib/Profile/profile.dart:1:8: Error: Not found: 'dart:js'
import 'dart:js';
^
I have already added the dependency dart:js, but still getting the same error.
Error:
Go to your flutter installed directory/.pub-cache/hosted/pub.dartlang.org/js-0.6.3-nullsafety.1/lib/js.dart
Delete or comment this line:
export 'dart:js' show allowInterop, allowInteropCaptureThis;
Then try again
I just del import 'package:js'. it works for me.
Sounds like an import issue as soon as you are trying to compile for a native application.
Try searching for and delte the incorrect dart:js import (import 'dart:js';).
Have a look at this GitHub issue #70373
EDIT: I have switched to the master channel and all working fine. Although I don't see any requirement of dart.js in your current code. so you can remove that too
ORIGINAL ANSWER:
I believe you are using stable channel so try to switch to beta channel.
Open your terminal and run,
$ flutter channel beta
Quoting pub.dev:
Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
js: ^0.6.2
Install it
You can install packages from the command line:with pub:
$ pub get
with flutter:
$ flutter pub get
Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.
Import it
Now in your Dart code, you can use:
import 'package:js/js.dart';
in my case just flutter clean solved the issue
Try using the js package: https://pub.dev/packages/js#-installing-tab-
You should try to use package:js instead of dart:js
Actually mine was solved with just a system restart and a "flutter clean" command. (yes I am using beta channel) But weird thing was the files were existed already but the dependencies somehow couldn't read from the dart packages.
You may not running the app on supported platform by library. In my case I was running on Android which library just supported Web as output. No need to clear cache or comment some code.
This solution allowed me to run tests using dart:js & without modifying my local flutter installation.
check if you are not using that package in your project just remove unused packages.
Step -1
Just remove dart:js
Step -2
Run on terminal "flutter clean"
Step -3
Run on terminal "flutter pub get"
Step -4
Run your project

can change background image of app for period of time in flutter?

i need to add changing background to my app.offer me a solution
code:
Widget testBGCarousel = new Container(
child: new Carousel(
children: [
new AssetImage('images/a.jpg'),
new AssetImage('images/b.jpg'),
new AssetImage('images/sc.jpg'),
].map((bgImg) => new Image(image: bgImg, width: 1500.0, height: 1500.0,
fit: BoxFit.cover)).toList(),
displayDuration: const Duration(seconds: 4),
),
);
pubspec.yaml :
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
share: ^0.5.3
flutter_webview_plugin: ^0.2.1+2
launch_review: ^1.0.1
carousel: ^0.1.0
error:
The current Dart SDK version is 2.1.0-dev.5.0.flutter-a2eb050044.
Because carousel 0.1.0 requires SDK version <2.0.0 and no versions of carousel match >0.1.0 <0.2.0, carousel ^0.1.0 is forbidden.
So, because quiz depends on carousel ^0.1.0, version solving failed.
pub get failed (1)
exit code 1
You have to check if the package is Dart 2.0 compatible, and looks like it is not : https://pub.dartlang.org/packages/carousel
I checked the issue opened : https://github.com/gbrvalerio/carousel/issues/11
The author updated the code but it was not published on pub Flutter packages repository.
So you have to add it manually, update your pubspec.yaml file
Change this:
carousel: ^0.1.0
To this:
carousel:
git:
url: git://github.com/gbrvalerio/carousel.git

Categories

Resources