Created
February 16, 2020 14:01
-
-
Save ryanlid/611345f082298c4abd91da9e45a94a82 to your computer and use it in GitHub Desktop.
按下处理
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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp( | |
title: "按下处理", | |
home: MyApp(), | |
)); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("按下处理"), | |
), | |
body: Center( | |
child: MyButton(), | |
), | |
); | |
} | |
} | |
class MyButton extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap: () { | |
final snackBar = SnackBar( | |
content: Text("你已按下啦"), | |
); | |
Scaffold.of(context).showSnackBar(snackBar); | |
}, | |
child: Container( | |
padding: EdgeInsets.all(12.0), | |
decoration: BoxDecoration( | |
color: Theme.of(context).buttonColor, | |
borderRadius: BorderRadius.circular(10.0), | |
), | |
child: Text("测试按钮"), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment