Created
December 18, 2023 04:05
-
-
Save dongsub-joung/7705445e277a64cb740dcf2c1b3dec26 to your computer and use it in GitHub Desktop.
1.A value of type 'Future<dynamic>' can't be returned from the method 'showDilong' because it has a return type of 'Future<void> Function()?'.dart
This file contains 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
import 'package:flutter/material.dart'; | |
class ScreenComment extends StatelessWidget { | |
Future<void> Function()? showDilong(BuildContext context) { | |
final TextEditingController _textFieldController = TextEditingController(); | |
return showDialog( | |
context: context, | |
builder: (context) { | |
return AlertDialog( | |
title: Text('TextField in Dialog'), | |
content: TextField( | |
onChanged: (value) {}, | |
controller: _textFieldController, | |
decoration: InputDecoration(hintText: "Text Field in Dialog"), | |
), | |
); | |
}); | |
} | |
void _showAlertDialog(BuildContext context) { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: const Text('Alert Dialog Title'), | |
content: const Text('This is the content of the alert dialog.'), | |
actions: <Widget>[ | |
TextButton( | |
child: const Text('Cancel'), | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
), | |
TextButton( | |
child: const Text('Confirm'), | |
onPressed: () { | |
// Handle the confirm action | |
}, | |
), | |
], | |
); | |
}, | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
final List<String> listing = <String>[ | |
'Build My website(nginx + Front)', | |
'Write the todo code(diesel + postgresql)', | |
'cargo publish todo app' | |
]; | |
final len = listing.length; | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Comment'), | |
), | |
body: CustomScrollView( | |
slivers: [ | |
SliverList( | |
delegate: SliverChildBuilderDelegate( | |
(context, index) => ListTile(title: Text('${listing[index]}')), | |
childCount: len, | |
), | |
), | |
], | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: _showAlertDialog(context), | |
child: const Icon(Icons.add), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment