flutter_overlay_window icon indicating copy to clipboard operation
flutter_overlay_window copied to clipboard

I can't display my data on the overlay window.

Open Tr0y2ooo opened this issue 1 year ago • 3 comments

I have wrote homepage.dart,there's a button,I add a function in onPress event. trailing: IconButton( icon: const Icon(Icons.map), onPressed: () async { _launchMapsLauncher( _selectedNavOp, address, latitude, longitude); _openFloatingWindow(context); /////////////////////////////////////////////////////////////////////////////////// void _openFloatingWindow (BuildContext context) async{ if (await FlutterOverlayWindow.isActive()) return; await FlutterOverlayWindow.showOverlay( enableDrag: true, overlayTitle: _selectedAddress!, overlayContent: 'Overlay Enabled', flag: OverlayFlag.defaultFlag, visibility: NotificationVisibility.visibilityPublic, positionGravity: PositionGravity.auto, height: (MediaQuery.of(context).size.height * 0.6).toInt(), width: WindowSize.matchParent, startPosition: const OverlayPosition(0, -259), ); } the Overlaywindow shows context of true_caller_overlay not the context i except to true_caller_overlay.dart import 'dart:developer';

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

class TrueCallerOverlay extends StatefulWidget { final String title;

const TrueCallerOverlay({Key? key, required this.title}) : super(key: key);

@override State<TrueCallerOverlay> createState() => _TrueCallerOverlayState(); }

class _TrueCallerOverlayState extends State<TrueCallerOverlay> {

@override void initState() { super.initState(); }

@override Widget build(BuildContext context) { return Material( color: Colors.transparent, child: Center( child: Container( padding: const EdgeInsets.symmetric(vertical: 5.0), width: double.infinity, decoration: BoxDecoration( color: Colors.black, // 將背景顏色設置為黑色 borderRadius: BorderRadius.circular(12.0), ), child: GestureDetector( onTap: () { FlutterOverlayWindow.getOverlayPosition().then((value) { log("Overlay Position: $value"); }); }, child: Stack( children: [ Column( children: [ ListTile( leading: Container( height: 80.0, width: 80.0, ), title: const Text( "aaaaaa", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold , color: Colors.white), ), ), ], ), Positioned( top: 0, right: 0, child: IconButton( onPressed: () async { await FlutterOverlayWindow.closeOverlay(); }, icon: const Icon( Icons.close, color: Colors.white, ), ), ), ], ), ), ), ), ); } } and my main.dart import 'dart:async'; import 'package:v2_0/auth/login_screen.dart'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; import '../overlays/true_caller_overlay.dart';

Future main() async { WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, );

runApp(const MyApp()); } @pragma("vm:entry-point") void overlayMain() { WidgetsFlutterBinding.ensureInitialized(); runApp( const MaterialApp( debugShowCheckedModeBanner: false, home: TrueCallerOverlay(title: '123',), ), ); }

class MyApp extends StatelessWidget { const MyApp({super.key});

@override Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, home: LoginScreen()); } }

Tr0y2ooo avatar May 27 '24 12:05 Tr0y2ooo