Created
January 19, 2023 19:35
-
-
Save frantovar/5beb39a1d5a36bfa3033998e26c17c0f to your computer and use it in GitHub Desktop.
ModelViewer with a dialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Viewer3DView extends StatelessWidget { | |
const Viewer3DView({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('3D Model'), | |
actions: [ | |
IconButton( | |
onPressed: () => _dialogBuilder(context), | |
icon: const Icon(Icons.info_outlined), | |
) | |
], | |
), | |
body: ModelViewer( | |
id: 'MyModel', | |
src: 'https://modelviewer.dev/shared-assets/models/shishkebab.glb', | |
), | |
); | |
} | |
Future<void> _dialogBuilder(BuildContext context) { | |
return showDialog<void>( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: const Text('Holly Dolly'), | |
content: const Text( | |
'Closing this dialog will broke model rotation controlls'), | |
actions: <Widget>[ | |
TextButton( | |
style: TextButton.styleFrom( | |
textStyle: Theme.of(context).textTheme.labelLarge, | |
), | |
child: const Text('OK'), | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
), | |
], | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment