Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

dart - How to use lowerbound in flutter?

I see that there's a package in flutter that would let me use binarySearch and lowerBound

https://api.flutter.dev/flutter/package-collection_collection/lowerBound.html

At first, binarySearch and lowerBound were undefined and using my IDE, I was told to import import 'package:flutter/foundation.dart';

I did and I'm now able to use binarySearch, but I am still not able to use lowerBound and there are no suggested imports for this.

The goal is to insert a value into a List<int> sorted by descending.

And I would like to do this.

Any ideas on why I'm not able to using lowerBound ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We have 2 binarySearch() methods in Flutter. One in Flutter build-in package flutter and another one in third party package collection.

When you imported import 'package:flutter/foundation.dart'; library, you used the first one.

According your url, you'd like to use package collection

https://api.flutter.dev/flutter/ ★package-collection_collection★ /lowerBound.html

So you should import package:collection/collection.dart directly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...