given the code below
import 'package:flutter/material.dart';
Future<void> _showMyDialog(BuildContext context) async => showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Success'),
content: const Text('nice job!'),
actions: <Widget>[
TextButton(
child: const Text('done'),
onPressed: Navigator.of(context).pop,
),
],
),
);
void main() => runApp(
const MaterialApp(
home: SafeArea(
child: MyHomePage(),
),
),
);
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Material(
child: Stack(
fit: StackFit.expand,
children: [
Positioned(
bottom: 25,
right: 25,
child: FloatingActionButton(
child: const Icon(Icons.message),
onPressed: () => _showMyDialog(context),
),
),
PageView.builder(
itemBuilder: (context, index) => Center(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width / 2,
child: const ColoredBox(
color: Color.fromRGBO(60, 30, 10, .5),
),
),
),
),
],
),
);
}
how do I make the button clickable without changing the order of the children in the stack and keeping the scroll view scrollable?
I have tried wrapping the PageView
in a GestureDetector
without results
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: null,
child: PageView.builder(
itemBuilder: (context, index) => ...
),
),