Flutter named parameter and OneSignal issue - flutter

I am working on a project which was built on Flutter 2.2.3 but I updated all the dependencies. Also, I have fixed many errors which were the result of upgrading the flutter from 2.2.3 to 2.5.2. Now i am facing an issue with two files. One issue is with the PersistentTabController and it is saying 'The named parameter is not found' for many lines like controller, navBarHeight, onItemSelected, screens, items. Well I am sharing the code. The left side is totally red. How can I fix that?
PersistentTabController(
controller: controller,
navBarHeight: MediaQuery.of(context).size.width > 768 ? 90 : 64,
onItemSelected: (item) {
int index = controller.index;
if (index == 0) {
setState(() {
appbarTitle = Languages.of(context).homeScreenTitle;
});
} else if (index == 1) {
setState(() {
appbarTitle = Languages.of(context).appointmentsScreenTitle;
});
} else if (index == 2) {
setState(() {
appbarTitle = Languages.of(context).favouriteScreenTitle;
});
} else if (index == 3) {
setState(() {
appbarTitle =
Languages.of(context).notificationsScreenTitle;
});
} else if (index == 4) {
setState(() {
appbarTitle = Languages.of(context).accountScreenTitle;
});
}
},
screens: _pages,
items: [
PersistentBottomNavBarItem(
icon: Icon(
Icons.home_outlined,
size: MediaQuery.of(context).size.width > 768 ? 40 : 24,
),
title: Languages.of(context).bottomNavHome,
activeColor: ColorConstants.primaryColor,
inactiveColor: ColorConstants.iconColor,
titleStyle: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 768 ? 20 : 12)),
PersistentBottomNavBarItem(
icon: Icon(
Icons.calendar_today_outlined,
size: MediaQuery.of(context).size.width > 768 ? 40 : 24,
),
title: Languages.of(context).bottomNavAppointments,
activeColor: ColorConstants.primaryColor,
inactiveColor: ColorConstants.iconColor,
titleStyle: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 768 ? 20 : 12)),
PersistentBottomNavBarItem(
icon: Icon(
Icons.favorite_border,
size: MediaQuery.of(context).size.width > 768 ? 40 : 24,
),
title: Languages.of(context).bottomNavFavourites,
activeColor: ColorConstants.primaryColor,
inactiveColor: ColorConstants.iconColor,
titleStyle: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 768 ? 20 : 12)),
PersistentBottomNavBarItem(
icon: Icon(
Icons.notifications,
size: MediaQuery.of(context).size.width > 768 ? 40 : 24,
),
title: Languages.of(context).bottomNavNotifications,
activeColor: ColorConstants.primaryColor,
inactiveColor: ColorConstants.iconColor,
titleStyle: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 768 ? 20 : 12)),
PersistentBottomNavBarItem(
icon: Icon(
Icons.person_outline,
size: MediaQuery.of(context).size.width > 768 ? 40 : 24,
),
title: Languages.of(context).bottomNavAccount,
activeColor: ColorConstants.primaryColor,
inactiveColor: ColorConstants.iconColor,
titleStyle: TextStyle(
fontSize:
MediaQuery.of(context).size.width > 768 ? 20 : 12)),
],
confineInSafeArea: true,
backgroundColor: Colors.white,
handleAndroidBackButtonPress: true,
resizeToAvoidBottomInset: true,
// This needs to be true if you want to move up the screen when keyboard appears.
stateManagement: false,
hideNavigationBarWhenKeyboardShows: true,
// Recommended to set 'resizeToAvoidBottomInset' as true while using this argument.
decoration: NavBarDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(1.0),
colorBehindNavBar: Colors.black,
),
popAllScreensOnTapOfSelectedTab: true,
popActionScreens: PopActionScreensType.all,
itemAnimationProperties: ItemAnimationProperties(
// Navigation Bar's items animation properties.
duration: Duration(milliseconds: 200),
curve: Curves.ease,
),
screenTransitionAnimation: ScreenTransitionAnimation(
// Screen transition animation on change of selected tab.
animateTabTransition: true,
curve: Curves.ease,
duration: Duration(milliseconds: 200),
),
navBarStyle: NavBarStyle.style6,
),
Also in another file, I am facing OneSignal issues like 'The method setInFocusDisplayType isn't defined for the type 'OneSignal' and 'The method 'setNotificationReceivedHandler isn't defined for the type 'OneSignal'.
Here is the code
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);
OneSignal.shared
.setNotificationReceivedHandler((OSNotification notification) {
this.setState(() {
outPutString =
"Received notification: \n${notification.jsonRepresentation().replaceAll("\\n", "\n")}";
});
How can i fix these?
I am sharing my pubspec.yaml file here.
name: test_app
description: A Test Application
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.0
shared_preferences: ^2.0.8
cached_network_image: ^3.1.0
flutter_rating_bar: ^4.0.0
url_launcher: ^6.0.12
country_code_picker: ^2.0.2
flutter_range_slider: "^1.5.0"
group_radio_button: ^1.0.1
carousel_slider: ^4.0.0
persistent_bottom_nav_bar: ^4.0.2
intl: ^0.17.0
provider: ^6.0.1
flutter_bloc: ^7.3.0
equatable: ^2.0.3
image_picker: ^0.8.4+2
dio: ^4.0.0
otp_text_field: ^1.0.2
path: ^1.7.0
mime: ^1.0.0
fluttertoast: ^8.0.8
date_format: ^2.0.4
html: ^0.15.0
flutter_calendar_carousel: ^2.0.3
onesignal_flutter: ^3.2.3
flutter_paytabs_bridge: ^2.1.1
http:
share: ^2.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
fonts:
- family: Quicksand
fonts:
- asset: assets/fonts/Quicksand/Quicksand-Bold.ttf
- asset: assets/fonts/Quicksand/Quicksand-Light.ttf
- asset: assets/fonts/Quicksand/Quicksand-Medium.ttf
- asset: assets/fonts/Quicksand/Quicksand-Regular.ttf
- asset: assets/fonts/Quicksand/Quicksand-SemiBold.ttf
- asset: assets/fonts/Quicksand/Quicksand-VariableFont_wght.ttf
assets:
- assets/images/
- assets/icons/

The problem is your plugins are updated but you are using methods outdated.
First issue seems like you are using PersistentTabController instead PersistentTabView or PersistentTabView.custom. Link documentation PersistentTab
And OneSignal plugin has the following methods:
OneSignal.shared.setNotificationWillShowInForegroundHandler((OSNotificationReceivedEvent event) {
// Will be called whenever a notification is received in foreground
// Display Notification, pass null param for not displaying the notification
event.complete(event.notification);
});
OneSignal.shared.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
// Will be called whenever a notification is opened/button pressed.
});
Link OneSignal documentation

Related

how to make a button at the bottom of the drop down list

to create the popup list i used dropdown_search
design example as I would like to see it
when I start searching through the elements of the list, a button for adding should pop up
or the button should be immediately when we start searching for the element
drop-down list
button bottom
I chose all possible methods in the library, but still I can't use it with the addition of a button
all code
https://github.com/dimapichuev2000/test_dropdownbutton
main.dart
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:dropdown_search/dropdown_search.dart';
import 'package:test_dropdownbutton/gym_model.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData().copyWith(
primaryColor: Colors.amber,
colorScheme: ThemeData().colorScheme.copyWith(
primary: Colors.orange,
),
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
final String title;
#override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final _multiKey = GlobalKey<DropdownSearchState<String>>();
Widget _customDropDownExample(BuildContext context, GymModel? item) {
if (item == null) {
return const Text(
"Выберите фитнесс центр",
style:
TextStyle(fontSize: 15, color: Color.fromRGBO(33, 33, 33, 0.6)),
);
}
return Container(
child: (item.avatar == "")
? ListTile(
contentPadding: EdgeInsets.all(0),
leading: const CircleAvatar(
radius: 25,
backgroundColor: Colors.white,
backgroundImage: NetworkImage(
'https://img.icons8.com/ios/50/000000/gum-.png'),
),
title: Text(item.gym),
subtitle: Text(
item.location,
),
)
: ListTile(
contentPadding: const EdgeInsets.all(0),
leading: CircleAvatar(
radius: 25,
backgroundImage: NetworkImage(item.avatar ?? ''),
),
title: Text(item.gym),
subtitle: Text(
item.location,
),
),
);
}
Widget _exitPopup(BuildContext context) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
padding: const EdgeInsets.only(top: 2),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
margin: EdgeInsets.all(8),
height: 30,
width: 30,
),
const Text(
"Фитнесс центр",
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
),
IconButton(
icon: Image.asset(
'assets/button_X.png',
width: 25,
height: 25,
fit: BoxFit.fill,
),
iconSize: 25,
onPressed: () {
Navigator.of(context).pop();
},
)
],
),
);
}
Widget _customPopupItemBuilderExample(
BuildContext context, GymModel? item, bool isSelected) {
return Container(
decoration: !isSelected
? null
: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.white,
),
child: ListTile(
selected: isSelected,
title: Text(item?.gym ?? ''),
subtitle: Text(item?.location ?? ''),
leading: (item!.avatar == "")
? const CircleAvatar(
radius: 25,
backgroundColor: Colors.white,
backgroundImage: NetworkImage(
'https://img.icons8.com/ios/100/000000/gum-.png'),
)
: CircleAvatar(
radius: 25,
backgroundImage: NetworkImage(item.avatar ?? ''),
)),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Key value Pair - DropdownButton'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: SingleChildScrollView(
child: DropdownSearch<GymModel>(
mode: Mode.BOTTOM_SHEET,
showSearchBox: true,
compareFn: (item, selectedItem) => item?.id == selectedItem?.id,
scrollbarProps:ScrollbarProps(
radius: Radius.circular(20),
thickness: 4,
),
onFind: (String? filter) => getData(filter),
dropdownSearchDecoration: const InputDecoration(
filled: true,
fillColor: Color(0xFFE3E3E4),
hintText: "Выберите фитнесс центр",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
contentPadding: EdgeInsets.fromLTRB(12, 3, 0, 0),
),
popupSafeArea:
const PopupSafeAreaProps(top: true, bottom: true),
// labelText: "Выберите фитнесс центр ",
onChanged: (data) {
print(data);
},
maxHeight: 850,
dropdownBuilder: _customDropDownExample,
popupItemBuilder: _customPopupItemBuilderExample,
dropDownButton: Image.asset('assets/dropButton.png',
color: Color(0xFF79818A)),
popupTitle: _exitPopup(context),
popupShape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
),
searchFieldProps: TextFieldProps(
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.search,
),
filled: true,
fillColor: Color(0xFFE3E3E4),
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
contentPadding: EdgeInsets.fromLTRB(12, 12, 8,0),
// labelText: "Поиск",
hintText: "Поиск",
hintStyle: TextStyle(fontSize: 17)),
),
),
),
),
],
),
),
);
}
Future<List<GymModel>> getData(filter) async {
var response = await Dio().get(
"https://my-json-server.typicode.com/dimapichuev2000/JSON_TEST/posts",
queryParameters: {"filter": filter},
);
final data = response.data;
if (data != null) {
return GymModel.fromJsonList(data);
}
return [];
}
}
gym_model.dart
class GymModel {
final String id;
final String location;
final String gym;
final String? avatar;
GymModel(
{required this.id,
required this.location,
required this.gym,
this.avatar});
factory GymModel.fromJson(Map<String, dynamic> json) {
return GymModel(
id: json["id"],
location: json["location"],
gym: json["gym"],
avatar: json["avatar"],
);
}
static List<GymModel> fromJsonList(List list) {
return list.map((item) => GymModel.fromJson(item)).toList();
}
#override
String toString() => gym;
}
pubspec.yaml
name: fitsupp_coach
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter_localizations:
sdk: flutter
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
pinput: ^1.2.2
intl: ^0.17.0
quiver: ^3.0.1+1
firebase_auth: ^3.3.5
firebase_core: ^1.11.0
dropdown_search: ^2.0.1
dio: ^4.0.4
provider: ^6.0.2
percent_indicator: ^4.0.0
dev_dependencies:
flutter_test:
sdk: flutter
# 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
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# 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/images/
- assets/images/DropDown/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: SF Pro Display
fonts:
- asset: fontsassets/SFProDisplay/SFProDisplay-Light.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Medium.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Black.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Bold.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Heavy.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Regular.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Semibold.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Thin.ttf
- asset: fontsassets/SFProDisplay/SFProDisplay-Ultralight.ttf
style: normal
- family: SF Pro Text
fonts:
- asset: fontsassets/SFProText/SF-Pro-Text-Light.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Medium.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Black.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Bold.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Heavy.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Regular.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Semibold.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Thin.otf
- asset: fontsassets/SFProText/SF-Pro-Text-Ultralight.otf
style: normal
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
flutter_intl:
enabled: true
There are many ways you can do that but the easiest and the most elegant solution in my opinion is the following:
Column(
children: [
Flexible(
child: ListView.builder(
shrinkWrap: true,
itemCount: 5,
itemBuilder: (BuildContext context, int i) {
return Text(i.toString());
},
),
),
ElevatedButton.icon(
onPressed: null,
icon: const Icon(Icons.abc),
label: const Text('next')),
],
);
Start with a Column widget and then add ListView.builder and button of your choosing, I use ElevatedButton.icon, as it's children. Now set the shrinkWrap setting in ListView.builder to true and finally wrap it with Flexible widget.
In your case, you can wrap your Container widget with a ListView.builder widget and if you get viewport.dart error just wrap it with either Flexible or Expanded, depending on how much space you want it to consume. Then you can add logic to check if you are at the last index, in which case you can show your button, this is kinda what the code it will end up looking like:
Flexible(
child: ListView.builder(
shrinkWrap: true,
itemCount: _listSavedOutsideThisWidget.length+1,
itemBuilder: (BuildContext context, int index) {
if (index == _listSavedOutsideThisWidget.length) {
return TextButton.icon(
onPressed: _onPressed(context),
icon: const Icon(Icons.upload_file),
label: const Text('Upload Data'));
}
return Container(
decoration: !isSelected
? null
: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.white,
),
child: ListTile(
selected: isSelected,
title: Text(item?.gym ?? ''),
subtitle: Text(item?.location ?? ''),
leading: (item!.avatar == "")
? const CircleAvatar(
radius: 25,
backgroundColor: Colors.white,
backgroundImage: NetworkImage(
'https://img.icons8.com/ios/100/000000/gum-.png'),
)
: CircleAvatar(
radius: 25,
backgroundImage: NetworkImage(item.avatar ?? ''),
)),
);
},
),
);
For this method to work you will have to create a List<GymModel> _listSavedOutsideThisWidget = [] variable outside the build function and populate it by changing the onFind method under DropdownSearch widget, like such:
onFind: (String? filter) async {
List<GymModel>> filteredList = await gedtData(filter);
setState(() => _listSavedOutsideThisWidget = filteredList);
// return getData(filter);
return filteredList; // if this doesn't work, try uncommenting the above line
}
Hope this helps. Feel free to ask more questions.
OK, this may not be the most elegant solution, but it does the trick.
First create a Model for the button:
class BottomButton {
final String? text;
BottomButton({
this.text,
});
}
Then you are going to want to change all the output types from GymModel? to dynamic:
Widget _customDropDownExample(BuildContext context, dynamic item)
Widget _customPopupItemBuilderExample(
BuildContext context, dynamic item, bool isSelected)
DropdownSearch<dynamic>
Future<List<dynamic>> getData(filter)
Now, in the _customDropDownExample function where you are checking if the item == null add another to see if item is !GymModel:
if (item == null || item is !GymModel) {
return const Text(
"Выберите фитнесс центр",
style: TextStyle(fontSize: 15, color: Color.fromRGBO(33, 33, 33, 0.6)),
);
}
Inside _customPopupItemBuilderExample function check to see if the item is GymModel if so then do exactly what you were doing before and if not then create a button widget of your choice, I used an ElevatedButton for simplicity:
if (item is GymModel) {
return Container(
decoration: !isSelected
? null
: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.white,
),
child: ListTile(
selected: isSelected,
title: Text(item.gym),
subtitle: Text(item.location),
leading: (item.avatar == "")
? const CircleAvatar(
radius: 25,
backgroundColor: Colors.white,
backgroundImage: NetworkImage("https://picsum.photos/200"),
)
: CircleAvatar(
radius: 25,
backgroundImage: NetworkImage(item.avatar ?? ''),
)),
);
} else {
return ElevatedButton(onPressed: () {}, child: Text(item.text));
}
Also write an another function to filter the result and assign it to filterFn attribute in DropDownSearch widget:
bool _filterItems(dynamic item, String? str) {
if (item is GymModel) {
return (item.gym.toLowerCase().contains(str!.toLowerCase()) ||
item.location.toLowerCase().contains(str.toLowerCase()));
}
return (item is BottomButton);
}
Finally inside getData function where you check if the data != null add your button model (BottomButton, in my case) to the list:
Future<List<dynamic>> getData(filter) async {
var response = await Dio().get(
"https://my-json-server.typicode.com/dimapichuev2000/JSON_TEST/posts",
queryParameters: {"filter": filter},
);
final data = response.data;
if (data != null) {
List<dynamic> res = GymModel.fromJsonList(data);
BottomButton button = BottomButton(text: "Good Luck!");
return [...res, button];
}
return [];
}

Initializing Flutter-Fire flutter Web

I can't figure out where is the problem output gives me Connection failed Here is the screen out put image. I'm trying to Initializing FlutterFire (Flutter Web). I'm doing it with the proper guidelines of official documentation https://firebase.flutter.dev/docs/overview#initializing-flutterfire.But can't figure out where I'm doing the mistake.
When I remove or comment on this part of codes it run.
// Check for errors
if (snapshot.hasError) {
return Center(
child: Text('Connection failed'),
);
}
Here is my main.dart
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Phatafut Admin Panel',
theme: ThemeData(
primaryColor: Colors.greenAccent,
),
home: MyHomePage(title: 'Phatafut Admin Panel'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
final _formKey = GlobalKey<FormState>();
// FirebaseServices _services = FirebaseServices();
var _usernameTextController = TextEditingController();
var _passwordTextController = TextEditingController();
#override
Widget build(BuildContext context) {
return Scaffold(
// // key:_formKey,
// appBar: AppBar(
// elevation: 0.0,
// title: Text('Grocery Store Admin Dashboard',style: TextStyle(color: Colors.white ),),
// centerTitle: true,
body: FutureBuilder(
// Initialize FlutterFire:
future: _initialization,
builder: (context, snapshot) {
// Check for errors
if (snapshot.hasError) {
return Center(
child: Text('Connection failed'),
);
}
// Once complete, show your application
if (snapshot.connectionState == ConnectionState.done) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF84c225), Colors.white],
stops: [1.0, 1.0],
begin: Alignment.topCenter,
end: Alignment(0.0, 0.0)),
),
child: Center(
child: Container(
width: 350,
height: 400,
child: Card(
elevation: 6,
shape: Border.all(color: Colors.green, width: 2),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
child: Column(
children: [
Image.asset('images/logo.png'),
Text(
'Grocery App ADMIN',
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 20),
),
SizedBox(
height: 20,
),
TextFormField(
controller: _usernameTextController,
validator: (value) {
if (value.isEmpty) {
return 'Enter UserName';
}
return null;
},
decoration: InputDecoration(
labelText: 'UserName',
prefixIcon: Icon(Icons.person),
contentPadding: EdgeInsets.only(
left: 20, right: 20),
border: OutlineInputBorder(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.primaryColor,
width: 2))),
),
SizedBox(
height: 20,
),
TextFormField(
controller: _passwordTextController,
validator: (value) {
if (value.isEmpty) {
return 'Enter Password';
}
if (value.length < 6) {
return 'Minimum 6 character required';
}
return null;
},
obscureText: false,
decoration: InputDecoration(
labelText: 'Minimum 6 Characters',
prefixIcon: Icon(Icons.vpn_key_sharp),
hintText: 'Password',
contentPadding: EdgeInsets.only(
left: 20, right: 20),
border: OutlineInputBorder(),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.primaryColor,
width: 2))),
),
],
),
),
Row(
children: [
Expanded(
child: TextButton(
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Colors.green,
onSurface: Colors.grey,
),
onPressed: () async {
if (_formKey.currentState.validate()) {
// _login(username: _usernameTextController.text, password: _passwordTextController.text);
}
},
child: Text(
'Login',
style: TextStyle(color: Colors.white),
)),
),
],
)
],
),
),
),
),
),
),
);
}
// Otherwise, show something whilst waiting for initialization to complete
return Center(
child: CircularProgressIndicator(),
);
},
),
);
}
}
here is my index.html
<!DOCTYPE html>
<html>
<head>
<base href="/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="admin_panel">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<title>admin_panel</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-analytics.js";
const firebaseConfig = {
apiKey: "********",
authDomain: "********",
projectId: "*********",
storageBucket: "************",
messagingSenderId: "******",
appId: "**************",
measurementId: "******"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>
<script>
var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
return;
}
scriptLoaded = true;
var scriptTag = document.createElement('script');
scriptTag.src = 'main.dart.js';
scriptTag.type = 'application/javascript';
document.body.append(scriptTag);
}
if ('serviceWorker' in navigator) {
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') {
console.log('Installed new service worker.');
loadMainDartJs();
}
});
}
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing ?? reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
reg.update();
waitForActivation(reg.installing);
} else {
// Existing service worker is still good.
console.log('Loading app from service worker.');
loadMainDartJs();
}
});
// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint <script> tag.
setTimeout(() => {
if (!scriptLoaded) {
console.warn(
'Failed to load app from service worker. Falling back to plain <script> tag.',
);
loadMainDartJs();
}
}, 4000);
});
} else {
// Service workers not supported. Just drop the <script> tag.
loadMainDartJs();
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
Here is my pubspec.yaml
name: admin_panel
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.10.0 <3.0.0"
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: ^1.0.2
firebase_core: ^1.5.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# 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:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Thanks in advance
Try adding these lines under <body> in your index.html, the documentation suggests using version 8.6.1 this way:
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>
And don't forget running flutter build web before deploying.

Why my font family aint working in Flutter?

Everything seems working just fine except the font family.Text animation is working but everytime i run my Flutter apps it runs on the normal default font.What should i do now?
children: [
AnimatedTextKit(
animatedTexts: [
TypewriterAnimatedText(
'Hello world!',
textStyle: const TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
fontFamily: 'Canterbury'
),
speed: const Duration(milliseconds: 200),
),
],
totalRepeatCount: 4,
pause: const Duration(milliseconds: 1000),
displayFullTextOnTap: true,
stopPauseOnTap: true,
)
],
)
),
);
}
}
Make sure to add the fonts to your pubspec.yaml file. Here is an example of how to properly implement them assuming the file storing your fonts is in the root folder of your project (not the lib)
assets:
...
fonts:
- family: Schyler
fonts:
- asset: fonts/Schyler-Regular.ttf
- asset: fonts/Schyler-Italic.ttf
style: italic

Error: Null safety features are disabled for this library in Flutter

I added non-nullabe in pubspec as well. I don't want to change my SDK version, cuz I have already been using it for other dependencies and it will cause errors if I change the version. Please let me know how can I remove this error. Please let me know how can i resolve this issue as i am new to Flutter
Error:
lib/BluetoothScanningDevices.dart:113:40: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
children: snapshot.data!
^
My pubspec.yaml file looks like this:
name: epicare
description: Epilepsy monitoring application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
analyzer:
enable-experiment:
- non-nullable
dependencies:
table_calendar: ^2.2.1
shared_preferences: ^0.5.4+5
permission_handler: ^5.0.0
contacts_service: ^0.3.10
url_launcher: ^5.4.2
flutter_switch: ^0.2.2
flutter:
sdk: flutter
custom_switch: ^0.0.1
charts_flutter: ^0.10.0
image_picker: ^0.6.7+22
loading_animations: ^2.1.0
flutter_spinkit: ^4.1.2
cupertino_icons: ^0.1.3
flutter_launcher_icons: ^0.9.0
flutter_local_notifications: ^1.4.4+2
focused_menu: ^1.0.0
fluttertoast: ^4.0.0
contact_picker: ^0.0.2
google_sign_in: ^3.3.0
http: ^0.12.0+4
provider: ^5.0.0
firebase_core: ^0.5.0
firebase_auth: ^0.18.0+1
flutter_blue: ^0.8.0
bluetooth_enable: ^0.1.1
flutter_bluetooth_serial: ^0.2.2
dev_dependencies:
flutter_test:
sdk: flutter
Code for using Bluetooth functionality:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'BluetoothConnectBand.dart';
import 'BluetoothConnectedSuccess.dart';
import 'package:flutter_blue/flutter_blue.dart';
class BluetoothScanningDevices extends StatefulWidget {
#override
_BluetoothScanningDevicesState createState() =>
_BluetoothScanningDevicesState();
}
class _BluetoothScanningDevicesState extends State<BluetoothScanningDevices> {
FlutterBlue flutterBlue = FlutterBlue.instance;
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xffE5E0A1),
elevation: 0,
centerTitle: true,
title: Text(
"Connect Band",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
),
),
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return BluetoothConnectBand();
},
),
);
},
),
actions: [
Padding(
padding: EdgeInsets.only(right: 5.0),
child: FlatButton(
onPressed: () {},
child: Text(
"Search",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.normal,
fontFamily: 'Montserrat',
),
),
),
)
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: size.height * 0.4,
width: size.width,
color: const Color(0xffE5E0A1),
child: Image.asset(
'assets/images/bluetooth.png',
)),
Container(
width: size.width,
padding: EdgeInsets.symmetric(vertical: 20),
child: Text(
"Scanning Available Devices...",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Montserrat',
),
textAlign: TextAlign.center,
),
),
StreamBuilder<List<BluetoothDevice>>(
stream: Stream.periodic(Duration(seconds: 2))
.asyncMap((_) => FlutterBlue.instance.connectedDevices),
initialData: [],
builder: (c, snapshot) => Column(
children: snapshot.data!
.map((d) => ListTile(
title: Text(d.name),
subtitle: Text(d.id.toString()),
trailing: StreamBuilder<BluetoothDeviceState>(
stream: d.state,
initialData: BluetoothDeviceState.disconnected,
builder: (c, snapshot) {
if (snapshot.data ==
BluetoothDeviceState.connected) {
return RaisedButton(
child: Text('OPEN'),
onPressed: (){}
);
}
return Text(snapshot.data.toString());
},
),
))
.toList(),
),
),
],
),
);
}
}
In the null safety world we use "!" to indicate that the variable won't be nullable, but in order to use these cool features the dart SDK version should be greater than 2.12.
the error message clearly states the line number where the problem exists, you need not change the version nor migrate, remove the "!" after snapshot.data on line 113 inside your BluetoothScanningDevices.dart file.
I have added a comment inside the code snippet where the change has to happen.
builder: (c, snapshot) => Column(
// Important: remove the exclamation after snapshot.data to fix the error.
children: snapshot.data!
.map((d) => ListTile(
title: Text(d.name),
subtitle: Text(d.id.toString()),
trailing: StreamBuilder<BluetoothDeviceState>(
stream: d.state,
initialData: BluetoothDeviceState.disconnected,
builder: (c, snapshot) {
if (snapshot.data ==
BluetoothDeviceState.connected) {
return RaisedButton(
child: Text('OPEN'),
onPressed: (){}
);
}
return Text(snapshot.data.toString());
},
),
))
There are ways to use non-nullable packages in legacy code, but they require invoking various commands with --no-sound-null-safety. Better would be to follow the steps to migrate your code, as indicated in https://dart.dev/null-safety/migration-guide.
How to use same package with differnt version
Use like this -> (analyzer above of environment)
version: 1.0.6+13
analyzer:
enable-experiment:
- non-nullable
environment:
sdk: ">=2.7.0 <3.0.0"
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: ^1.0.2
flutter_bloc: ^6.1.1
bloc_provider: ^0.7.0+3
provider: ^4.3.2+3
shared_preferences: ^0.5.12+4
package_info: ^2.0.0
#firebase
firebase_core: ^1.1.0
firebase_analytics: ^8.0.2
firebase: ^9.0.1
firebase_crashlytics: ^2.0.2
dependency_overrides:
firebase_core_platform_interface: ^4.0.0
plugin_platform_interface: ^2.0.0
http: ^0.13.0
http_parser: ^4.0.0
shared_preferences: ^2.0.5
path_provider_windows: ^2.0.0
path_provider_platform_interface: ^2.0.0
path_provider_linux: ^2.0.0
dev_dependencies:
flutter_test:
sdk: flutter

Having a small problem with my flutter app. I'm unable to print location value on the screen. What should be done?

I'm trying to create a flutter weather app. It's my first time creating an app and learning to code. So far it's good, but I have one slight problem. I'm unable to print or show the location on the screen. İt's supposed to be at the very top of the devices screen.
When I run the app on an Emulator, it does show the current location of the device. But when I run the app on a physical device (OnePlus 5 and Galaxy S10), It doesn't show the location.
As you will see below, I'm also unable to print the location into the console.
I have 2 .dart files. Code in both files are provided below.
Other than that everything works perfectly. No errors are being shown.
What am I missing or what have I done wrong. Thanks for the help.
main.dart:
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'GetLocation.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
void main() {
runApp(AuraWeather());
}
class AuraWeather extends StatefulWidget {
#override
_AuraWeatherState createState() => _AuraWeatherState();
}
class _AuraWeatherState extends State<AuraWeather> {
var apiKey = '******************************';
var description;
var city;
var maxTemp;
var minTemp;
var temp;
#override
Widget build(BuildContext context) {
getLocation();
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(displayBackground()),
),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaY: 2, sigmaX: 2),
child: Container(
color: Colors.black.withOpacity(0.5),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
Container(
child: Center(
child: Text(
'$city',
style: TextStyle(
fontSize: 35,
color: Colors.white,
),
),
),
),
Container(
child: Icon(
FontAwesomeIcons.locationArrow,
color: Colors.white,
),
),
Container(
margin: EdgeInsets.only(top: 80),
child: Text(
'$temp' + '°',
style: TextStyle(
fontSize: 50,
color: Colors.white,
fontWeight: FontWeight.w600),
),
),
],
),
Container(
margin: EdgeInsets.only(top: 30),
child: Icon(
Icons.wb_sunny,
color: Colors.white,
size: 100,
),
),
Container(
child: Center(
child: Text(
'$maxTemp ° | $minTemp °',
style: TextStyle(fontSize: 20, color: Colors.white),
),
),
),
Container(
child: Text(
'$description',
style: TextStyle(fontSize: 20, color: Colors.white),
),
),
Container(
child: FlatButton(
child: Icon(
Icons.refresh,
color: Colors.white,
size: 40,
),
color: Colors.transparent,
onPressed: () {
setState(
() {
getLocation();
},
);
},
),
),
],
),
),
),
),
),
);
}
// display background images based on current time
displayBackground() {
var now = DateTime.now();
final currentTime = DateFormat.jm().format(now);
if (currentTime.contains('AM')) {
return 'images/Blood.png';
} else if (currentTime.contains('PM')) {
return 'images/Sun.png';
}
}
//getLocation
void getLocation() async {
Getlocation getlocation = Getlocation();
await getlocation.getCurrentLocation();
print(getlocation.latitude);
print(getlocation.longitude);
print(getlocation.city);
city = getlocation.city;
getTemp(getlocation.latitude, getlocation.longitude);
}
//Get current temp
Future<void> getTemp(double lat, double lon) async {
http.Response response = await http.get(
'https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&appid=$apiKey&units=metric');
//print(response.body);
var dataDecoded = jsonDecode(response.body);
description = dataDecoded['weather'][0]['description'];
temp = dataDecoded['main']['temp'];
temp = temp.toInt();
maxTemp = dataDecoded['main']['temp_max'];
maxTemp = maxTemp.toInt();
minTemp = dataDecoded['main']['temp_min'];
minTemp = minTemp.toInt();
print(temp);
}
}
GetLocation.dart:
import 'package:geolocator/geolocator.dart';
class Getlocation {
double latitude;
double longitude;
String city;
//Get current location
Future<void> getCurrentLocation() async {
try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
latitude = position.latitude;
longitude = position.longitude;
city = await getCityName(position.latitude, position.longitude);
} catch (e) {
print(e);
}
}
//Get city name
Future<String> getCityName(double lat, double lon) async {
List<Placemark> placemark =
await Geolocator().placemarkFromCoordinates(lat, lon);
print('city name is: ${placemark[0].locality}');
return placemark[0].locality;
}
}
Console window:
Performing hot reload...
Syncing files to device ONEPLUS A5000...
Reloaded 0 of 587 libraries in 251ms.
I/flutter (13296): city name is:
I/flutter (13296): 41.0179339
I/flutter (13296): 28.6239036
I/flutter (13296):
I/flutter (13296): 20
Pubspec:
name: com
description: A new Flutter application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number
separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
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.2
intl: ^0.16.1
geolocator: ^5.3.1
http: ^0.12.0+4
sunrise_sunset: ^1.0.2
font_awesome_flutter: ^8.5.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# 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:
- images/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.auraweather">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="auraweather"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
its seems good code, but something is absent here.
first: where is your location permission request?
Second : why dont use initState for override
getLocation();
and in final step, u must implement all requirements for Geolocator plugin.
check these steps and update me in comment.