diff --git a/app/lib/common/widgets/share_receive.dart b/app/lib/common/widgets/share_receive.dart index d605fe099..553454f1c 100644 --- a/app/lib/common/widgets/share_receive.dart +++ b/app/lib/common/widgets/share_receive.dart @@ -12,7 +12,6 @@ class ShareReceive extends StatefulWidget { class _ShareReceiveState extends State { late StreamSubscription _intentDataStreamSubscription; - List? list; @override void initState() { super.initState(); @@ -20,9 +19,6 @@ class _ShareReceiveState extends State { // the memory _intentDataStreamSubscription = FlutterSharingIntent.instance.getMediaStream() .listen((sharedFiles) { - setState(() { - list = sharedFiles; - }); // ignore: avoid_print print( "Shared: getMediaStream ${sharedFiles.map((f) => f.value).join(",")}"); @@ -36,26 +32,12 @@ class _ShareReceiveState extends State { // ignore: avoid_print print( "Shared: getInitialMedia ${sharedFiles.map((f) => f.value).join(",")}"); - setState(() { - list = sharedFiles; - }); }); } @override Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Container( - margin: EdgeInsets.symmetric(horizontal: 24), - child: Text('Sharing data: \n${list?.join("\n\n")}\n')), - ), - ), - ); + return SizedBox.shrink(); } @override void dispose() { diff --git a/app/lib/login/pages/login.dart b/app/lib/login/pages/login.dart index f3146798a..530231464 100644 --- a/app/lib/login/pages/login.dart +++ b/app/lib/login/pages/login.dart @@ -1,6 +1,7 @@ import 'package:dropdown_button2/dropdown_button2.dart'; import '../../../common/module.dart'; +import '../../../common/widgets/share_receive.dart'; import '../models/lab.dart'; import 'cubit.dart'; @@ -16,44 +17,49 @@ class LoginPage extends HookWidget { Widget build(BuildContext context) { final dropdownValue = useState(labs.first.name); - return BlocProvider( - create: (context) => cubit ?? LoginPageCubit(), - child: BlocBuilder( - builder: (context, state) { - return Scaffold( - body: SafeArea( - child: Stack( - children: [ - Positioned.fill( - child: Align( - alignment: Alignment.center, - child: SvgPicture.asset( - 'assets/images/logo.svg', + return Stack( + children: [ + ShareReceive(), + BlocProvider( + create: (context) => cubit ?? LoginPageCubit(), + child: BlocBuilder( + builder: (context, state) { + return Scaffold( + body: SafeArea( + child: Stack( + children: [ + Positioned.fill( + child: Align( + alignment: Alignment.center, + child: SvgPicture.asset( + 'assets/images/logo.svg', + ), + ), ), - ), - ), - Positioned( - child: Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: const EdgeInsets.all(16), - child: state.when( - initial: () => - _buildInitialScreen(context, dropdownValue), - loadingUserData: CircularProgressIndicator.new, - loadedUserData: () => _buildLoadedScreen(context), - error: (message) => - _buildErrorScreen(context, message), + Positioned( + child: Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.all(16), + child: state.when( + initial: () => + _buildInitialScreen(context, dropdownValue), + loadingUserData: CircularProgressIndicator.new, + loadedUserData: () => _buildLoadedScreen(context), + error: (message) => + _buildErrorScreen(context, message), + ), + ), ), ), - ), + ], ), - ], - ), - ), - ); - }, - ), + ), + ); + }, + ), + ), + ], ); }