Flutter better player how to use onControlsVisibilityChanged - flutter

im using better player and i want to build my own custom controls but i don't know what i have to do with this parameter customControlsBuilder: (controller, onPlayerVisibilityChanged) => this param onPlayerVisibilityChanged how do i use it?
here is my code, im using CustomControlsWidget from the documentation but there is no clues on how use this onPlayerVisibilityChanged
controlsConfiguration: BetterPlayerControlsConfiguration(
controlsHideTime: const Duration(milliseconds: 1000),
controlBarColor: Colors.black12,
playerTheme: BetterPlayerTheme.custom,
customControlsBuilder: (controller, onPlayerVisibilityChanged) =>
CustomControlsWidget(
controller: controller,
onControlsVisibilityChanged: onPlayerVisibilityChanged,
),
),

Related

Loading images as icons in flutter_map

I am trying to set images coming from my database as icons for every point in the map. So far it kind of works , but it is to slow to load images and I believe this would not be scalable in the future. Futhermore, the app, at least in debug mode, crashes with out of memory issues.
Currently, I am using flutter_maps package to display my map:
return FlutterMap(
options:
MapOptions(
//center: tomtomCenter,
zoom: 1.0),
layers: [
TileLayerOptions(
minNativeZoom: 1.0,
backgroundColor: Colors.transparent,
urlTemplate:
"https://api.tomtom.com/map/1/tile/basic/main/"
"{z}/{x}/{y}.png?key={apiKey}",
attributionBuilder: (_) {
return const Text("© OpenStreetMap contributors");
},
additionalOptions: {"apiKey": TOMTOM_APIKEY},
),
MarkerLayerOptions(
markers: [
//_buildMarker( tomtomCenter, 'tomtomCenter'),
for (var mark in snapshot.data)
//{
_buildMarker(LatLng(mark['latitude'], mark['longitude']), 'Others', mark['DogImg'].url.toString())
//}
],
),
],
);
}
every point is defined in this function:
Marker _buildMarker(LatLng latLng, String currentLocation, String dogimg) {
return Marker(
point: latLng,
width: 10.0,
height: 10.0,
//anchorPos: AnchorPos.exactly(Anchor(2, 2)),
builder: (BuildContext context) =>
ClipRRect(child: Image.network(dogimg),)
);
}
I do not think that loading that amount of images through http request is the best idea, right?
I saw in other packages like google maps that load images (in that case from assets but there should be also for network requests) which look lighter
BitmapDescriptor markerbitmap = await BitmapDescriptor.fromAssetImage(
ImageConfiguration(),
"assets/images/bike.png",
);

When I view a page that contains YoutubePlayerController, the next page stops working

Problem
The widget on the next page after loading YoutubePlayerIFrame will not work.
For example, suppose you I have A and B Stateful Widgets.
First A is loaded, where YoutubePlayerIFrame is called.
You can press the button in A, but when you move to B, the screen freezes there.
I think this is the cause of youtube_player_iframe, but page transitions may be cause, so I will write the details.
Detail
I’m developing web app using youtube_player_iframe.
I wrote the following YoutubePlayerIFrame in A StatefulWidget.
YoutubePlayerIFrame(
controller: YoutubePlayerController(
initialVideoId: "NVzIALG7CUc",
params: YoutubePlayerParams(
showVideoAnnotations: false,
autoPlay: false,
startAt: Duration(seconds: 0),
showControls: true,
showFullscreenButton: false,
),
),
aspectRatio: 16 / 9,
),
Video has displayed correctly.
Page transition
Loading other pages with this code;
runApp(MaterialApp(
onGenerateRoute: (settings){
Widget wid = Home();
switch(settings.name){
case ...........
}
return PageRouteBuilder(
settings: settings,
pageBuilder: (_, __, ___) => wid,
transitionsBuilder: (_, a, __, c) =>
FadeTransition(opacity: a, child: c));
)
Then call this;
Navigator.of(context).pushReplacementNamed('/' + path);
When I remove YoutubePlayerIFrame from code, it works.
What should I do?
This is not correct but when I do this, it works better.
Just paste YoutubePlayerIFrame() in all pages.
Still need answer...
I gave up to use youtube_player_iframe.
So I decided to show YouTube video with webviewx.
This works better so far.

how to use Gesture Detector "onTap" to navigate to some other page?

How can i navigate from one page to another using gesture Detector ?
this is what i have done so far , i have also imported the login_page.dart but the gestureDetector is giving the error "undefined login_page"
GestureDetector(
onTap: () {
pageController.animateToPage(
login_page,
duration: Duration(milliseconds: 400),
curve: Curves.linear,
);
},
child: Text("GET STARTED NOW"),
),
Please use the below code in onTap: function. ***
Change the 4th line of the code.
GestureDetector(
onTap: () {
pageController.animateToPage(
HereIsTheClassNameOfYourPage(),//Please type the class name of your login_page class
duration: Duration(milliseconds: 400),
curve: Curves.linear,
);
},
child: Text("GET STARTED NOW"),
),
flutter dev also has a sample article for this
https://flutter.dev/docs/cookbook/animation/page-route-animation
Animates the controlled PageView from the current page to the given page.
The animation lasts for the given duration and follows the given curve. The returned Future resolves when the animation completes.
The duration and curve arguments must not be null.
Future animateToPage (
int page,
{#required Duration duration,
#required Curve curve}
)
Your GestureDetector syntax is correct but you passed wrong argument to animateToPage.
according the flutter api docs:
Future<void> animateToPage (
int page,
{#required Duration duration,
#required Curve curve}
)
this will Animate the controlled PageView from the current page to the given page.
Your login_page var must be a position of a page. you dont declare it correctly.
more information: animateToPage docs

The named parameter onImageTaped isn't defined

I want to implement a functionality where if an image is clicked, then it should navigate to a new page. Below code was working perfectly until recently when it showed me a squiggly red error underneath the function onImageTap.
child: new Carousel(
boxFit: BoxFit.cover,
images: list,
onImageTap: (imageIndex) {
Navigator.of(context).push(
new MaterialPageRoute(
builder: (context) => new DishDetails(
detail_name:
snapshot.data[imageIndex].data["title"],
detail_picture: snapshot
.data[imageIndex].data["image"]),
),
);
},
autoplay: false,
dotSize: 4.0,
indicatorBgPadding: 4.0,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 1000),
)));
When I hover over the function, I get the following error message:
The named parameter onImageTap isn't defined. Try correcting the name
to an existing named parameter or defining a new parameter with this
name
Can someone tell me how I can resolve this issue.
As you mentioned it was working earlier, so I believe you are using some 3rd party package which have Carousel widget and in one of its previous versions it had onImageTap, you unknowingly updated the plugin and they must have removed it or replaced it with something else.
Solution:
So, you can either use the previous version which had onImageTap property or use something else for it.
You may want to wrap your Carousel in a GestureDetector and handle onTap like:
GestureDetector(
onTap: () {},
child: Carousel(...)
)

How to create custom AnimatedIcon - Flutter

I know that icon use AnimatedIcon from Flutter package. But the available icons doesn't fit my needs. What i want is to build/draw my own AninimatedIcon (from default IconData or not). Is there any way to achieve this?
Please see an example Here
Just add the plugin, set the dependencies, imports and use it like this:
AnimateIcons(
startIcon: Icons.add,
endIcon: Icons.close,
size: 60.0,
onStartIconPress: () {
print("Clicked on Add Icon");
},
onEndIconPress: () {
print("Clicked on Close Icon");
},
duration: Duration(milliseconds: 500),
color: Theme.of(context).primaryColor,
clockwise: false,
),
used flare for icon animation https://www.2dimensions.com/