In my project when I create a new widget then AndroinStudio suggests me to import cuppertino library for the widget.
How to use material library for imports by default as my project is only Android project?
"as my project is only Android project"
What difference does that make? You can use Material Design with every Flutter platform.
Some editors could suggest you to import that library, but to remove errors when creating a new Widget class, you should:
import 'package:flutter/widgets.dart';
Related
I have a question about a reusable font awesome widget for Flutter that I am trying to create.
I am getting an error in Android Studio for Windows that, "The method 'FaIcon' isn't defined for the type 'IconContent'."
Below is how I set up the reusable widget. I found this advice but not sure how to implement: "Use the FaIcon Widget + FontAwesomeIcons class for the IconData"
https://gist.github.com/countrymusicfy/3c5aa155063b49bf5d07e89241bc637b
Any suggestions would be greatly appreciated!
You are missing import statement
You should include both in pubspec.yaml file and in your dart file.
Add import statement on your dart file
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Add dependecy on your pubspec.yaml
dependencies:
font_awesome_flutter: ^9.1.0
I'm moving the first steps with Flutter and I was wondering if is possible to use tailwinds styles and components.
thank you
Well, i don't think there is an equivalent to MaterialApp for Tailwind CSS. but you can try this package:
https://pub.dev/packages/tailwind_colors
And also building your own.
flutter devs for this issue I created a package that can be used as Tailwind CSS styling for your flutter projects here you can check it:
https://pub.dev/packages/tailwind_cli
How to create (and is it a good practice) a Flutter app which shows Cupertino UI widgets at iOS and Material UI widgets at Android with same functionality?
Import import 'dart:io'
And then in your widget make if statement
if(Platform.isIOS){
...
} else {
...
}
I found Flutter Platform Widgets package, works fine
I would like to show the native date picker depending on the device. For example UIDatePicker if it's iOS.
I've tried to add SelectDateTextField inside my widget and it works, but it looks like the Android one. Does anyone have any recommendations?
You should check the Platform then need to write specific widgets as per your need.
Use the APIs provided by the Dart.
Example:
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
Your Widget
Platform.isIOS ? CupertinoWidget() : MaterialWidget()
I'm using classes from a new dart file in flutter, but it doesn't use the same dependencies and autocompletes as my main.dart file even after importing import 'package:flutter/material.dart'; and import 'package:flutter/services.dart';. What am I doing wrong?
I refactored my new files as dart files and they all ended with .dart. This wasn't an explicit direction on any of the tutorials.