I used url_strategy in flutter web channel stable and beta.
I run flutter web in Landscape its work (image 1)
but when I changed Dimensions to Samsung or motog4 or iphone 5s does not work.(image 2),
this is my code:
import 'package:url_strategy/url_strategy.dart';
void main() {
// Here we set the URL strategy for our web app.
setPathUrlStrategy();
runApp(MyApp());
}
Image 1
Image 2
This error occurred because of index.html was old.
I just delete old web folder and create new web folder .
run below code in terminal and create new web folder with new index.html
flutter create .
Related
I am using the flutter course "Get to know Firebase for Flutter" from https://firebase.google.com/codelabs/firebase-get-to-know-flutter#4.
I am in step_02 and I have added the following recommended code from stage 5.
import 'package:firebase_auth/firebase_auth.dart'; // new
import 'package:firebase_core/firebase_core.dart'; // new
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart'; // new
import 'firebase_options.dart'; // new
import 'src/authentication.dart'; // new
import 'src/widgets.dart';
Later in this stage there is a Test it section. However it fails because there is no firebase_options.dart file. How do I generate this file.
Thank you.
Previously you had to download the google-service.json and GoogleService-Info.plist from the Firebase console and place them in the android and ios folders in your Flutter app.
Starting with Flutter 2.8, there is a new way to initialize a Firebase project within Flutter to bypass this step.
Create project in Firebase console, but you don't need to download the files mentioned or change build.gradle files
Install Firebase CLI here
run dart pub global activate flutterfire_cli in your Flutter project
run flutterfire configure
This will start a command line interface for you to select the Firebase projects you want to link to the Flutter project. After you complete this, a firebase_options.dart file will be generated in your lib/ folder.
Finally, to initialize Firebase in your main.dart:
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(MyApp());
}
PD: After updating to the new initialization method, Crashlytics and Analytics stopped working for me and I had to revert to the old initialization method. I don't think this new method is quite there yet. Guide for the old method.
The firebase_option file automatically generates after Flutter successfully configures your firebase project with your flutter app. For Android, make sure you've added the google-services.json file to your Android>app root directory and for ios, GoogleService-info.plist file into the root of your Xcode project as well as all targets.
If you're still having problems, I'd suggest using the Firebase CLI direct from the terminal to configure your firebase project.
From your project root terminal, command:
$ flutterfire configure
// This requires the Firebase CLI to work.
Select firebase project by hitting return or enter. Next you'll be asked to select which platforms the configuration should support, e.g. android, ios, web. If you haven't created some of these in the firebase console, don't worry as it will create and register it for you in this step and update the android build.gradle files.
** Proceed to step 4 if you already have the firebase_core plugin installed. **
Install the latest version of the firebase_core plugin by running this command from your project root directory:
$ flutter pub add firebase_core
Add imports to the main file:
import 'package:firebase_core/firebase_core.dart'; //
import 'firebase_options.dart'; // Generated file
Update your main function to initialize firebase with this async function:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options:
DefaultFirebaseOptions.currentPlatform);
runApp(const YourAppName());
}
Delete the google-services.json and google.plist files if you had these installed before.
$ flutter clean
$ flutter run
See the FlutterFire documentation for more information.
After completing the instructions provided by Bugzilla, I was able to locate the firebase_options.dart file in the lib directory. I changed the path of the import from 'firebase_options.dart' to '../firebase_options.dart' and it worked for me.
Solved this by removing my existing Firebase project and creating a new one, disabling Google Analytics.
I am fairly new to the dart and flutter. I'd like to make an installer for an android app running on windows by flutter language. To execute adb commands I am using Process.run() with adb platform-tools path which is currently stored on my desktop. I'd like to have this folder stored inside my flutter .exe or somewhere near finalapp.exe when I'll build it with the command flutter build windows so the windows app can still use and access platform-tools without changing the path to it. (I am imagining to work like this: I will create a .exe app, then I will open it on another computer with clean windows install and the app [stored inside the platform-tools] could still be installed by platform-tools stored inside the same .exe) How can I achieve it, please?
Here is my code:
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'installation_and_permissions.dart' as installer;
var stdoutCommand = "", stderrCommand = "", deviceName = "";
Future<void> main() async {
await Process.run(
'adb',
['devices'],
workingDirectory: "assets\\platform-tools",
runInShell: true,
).then((ProcessResult res) {
stdoutCommand = res.stdout;
deviceName = stdoutCommand.substring(26, 34);
stderrCommand = res.stderr;
print(res.stdout);
print(res.stderr);
});
//await installer.installApp();
//await installer.grantPermissions();
runApp(const MyApp());
}
Right now I have my assets (platform-tools and apk I want to install) stored in folder assets and in pubspecs.yaml assets are added:
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets\platform-tools
- assets\platform-tools\app-release-v3.1.01.apk
I googled a lot but I am not a native English speaker and I was unable to find a solution.
I want to using entry-point in my flutter 2.10.3 project, so I tried to write a demo file like this:
void main() {
print("main");
}
#pragma('vm:entry-point')
void entryPoint() {
print("entry-point");
}
when I run this project, it print the main but did not print the entry-point. why the entry-point did not work? the log output like this:
Launching lib/main.dart on iPhone Xʀ in debug mode...
Running Xcode build...
Xcode build done. 19.8s
Debug service listening on ws://127.0.0.1:64706/lkdcvnIiXyQ=/ws
Syncing files to device iPhone Xʀ...
flutter: main
you must attach enterpoint method into flutter engine by java and kotlin or swift (write native code) also
follow this article
https://medium.com/#vad.pinchuk/multiple-entry-android-application-with-flutter-or-alternative-ways-to-restrict-access-to-1260e097ef9f
I can't get a web release from my flutter app
when I use flutter build web I see this Error : Missing index.html
Then I run the flutter create but I facing by this Error : No option specified for the output of directory. Create a new flutter project.
However the my project is a new project and I have not made any changes to it
I forgot the last point "." of flutter create
flutter create is false
flutter create . is true
I want to do integration testing in Flutter. The tutorial I follow gives the following procedure:
Add the flutter_driver package to pubspec:
dev_dependencies:
flutter_driver:
sdk: flutter
Enable the Flutter driver extension and add a call to
the enableFlutterDriverExtension() function in main.dart.
Run the integration test by using the flutter drive command:
flutter drive --target=my_app/test_driver/my_test.dart
My problem is with understanding step 2. It's not clear to me where in Android Studio do you enable the driver extension and where exactly in main.dart do you call the function enableFlutterDriveExtension().
I also have problems with the third step. After running the said command, it says in my terminal that
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to set up Flutter, run the following command:
git clone -b stable https://github.com/flutter/flutter.git
You have to add this code inside the test_driver/app.dart file.
import 'package:flutter_driver/driver_extension.dart';
import 'package:[YOUR_APP]/main.dart' as app;
void main() {
// This line enables the extension
enableFlutterDriverExtension();
// Call the `main()` function of your app or call `runApp` with any widget you
// are interested in testing.
app.main();
}
You can find more info on the official Flutter documentation site (Steps 3 & 4):
https://flutter.dev/docs/cookbook/testing/integration/introduction
Good luck ;)
In order to run integration test in flutter, you need to create "test_driver" directory inside app root dir. Than you need to create two files inside "test_driver" folder.
Lets call first file "app.dart" and there you need to instrument your app(answer above).
Than you need to create your test file, which needs to be called "app_test.dart" and here you write your actual test code.
When you want to run that test, just run "flutter drive --target=test_driver/app.dart".
About step 3 in your question, check if you set flutter home properly and after adding flutter_driver dependency, run "packages get".