Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create multiple overlay window. #97

Closed
jijormathew opened this issue Feb 13, 2024 · 4 comments
Closed

Unable to create multiple overlay window. #97

jijormathew opened this issue Feb 13, 2024 · 4 comments

Comments

@jijormathew
Copy link

Hello, how can I make numerous overlay windows with this package? I should also be able to close each window separately.

@saurabhkumar8112
Copy link

Please try to add minimal example of the code that you're using. As it says in the docs and sample example creating a new overlay should be as simple as simply calling showOverlay

@jijormathew
Copy link
Author

import 'dart:async';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';

import 'news_data.dart';

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@OverRide
State createState() => _MyHomePageState();
}

class _MyHomePageState extends State {

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Top Stories'),
centerTitle: false,
titleTextStyle: const TextStyle(
fontSize: 30,
color: Colors.black)),
body: ListView.separated(
shrinkWrap: true,
separatorBuilder: (context, idx) {
return const Divider();
},
itemCount: getNewsStories().length,
itemBuilder: (context, idx) {
final article = getNewsStories()[idx];
return ListTile(
onLongPress: (){
_closeOverlayWindow();
},
key: Key('$idx ${article.hashCode}'),
title: Text(article.title),
subtitle: Text(article.description),
onTap: () {
_showOverlayWindow();
},
);
},
));

}
_showOverlayWindow() async {
bool status = await FlutterOverlayWindow.isPermissionGranted();
if(!status){
status = await FlutterOverlayWindow.requestPermission() ?? false;
setState(() {
});
}else{
await FlutterOverlayWindow.showOverlay(alignment: OverlayAlignment.centerLeft,height: 200,width: 300,enableDrag: true,flag: OverlayFlag.defaultFlag,positionGravity: PositionGravity.auto);
}
}
_closeOverlayWindow() async {
await FlutterOverlayWindow.closeOverlay();
}
} This is the example code that I'm attempting to run. I want to launch an overlay window as I press each article, not replace the one that's already open.

@ducviet321
Copy link

@jijormathew Could you put it in a code block?

By the way, is there any example of using & communicating between multiple of windows?

@X-SLAYER
Copy link
Owner

X-SLAYER commented Mar 3, 2024

For the moment this package works only on displaying single overlay

@X-SLAYER X-SLAYER closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants