ArizArmeidi / FlutterWeather

Weather app created using Flutter and Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error: 'SearchBar' isn't a function

zeroyou opened this issue · comments

[. (invocation_of_non_function at [flutter_weather] lib\Screens\homeScreen.dart:63)](error: The name 'SearchBar' is defined in the libraries 'package:flutter/src/material/search_anchor.dart (via package:flutter/material.dart)' and 'package:flutter_weather/widgets/searchBar.dart'. (ambiguous_import at [flutter_weather] lib\Screens\homeScreen.dart:63))

I see that too - the error says there is an ambiguity with the imports between 'package:flutter/material.dart' and '../widgets/searchBar.dart' since they both have a component named SearchBar.

To fix that, you can name one of them with an alias to differentiate. So instead of import '../widgets/searchBar.dart', replace with import '../widgets/searchBar.dart' as widgetSearch (widgetSearch is just an example, you can name it whatever you want). And in the code where it is used, use it with the prefix (e.g.widgetSearch.SearchBar())

import 'package:flutter/material.dart' hide SearchBar;

this will be fixed in the upcoming release along with a new UI update. currently I'm still busy with work but I'll release it ASAP