Created
April 20, 2020 16:05
-
-
Save stegrams/7d70597fea5ce9e2db2d62638bf329ad to your computer and use it in GitHub Desktop.
Fetch an image from the web with a tap on a placeholder.
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'; | |
| import 'dart:math' as math; | |
| final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: Scaffold( | |
| body: MyWidget(), | |
| ), | |
| ); | |
| } | |
| } | |
| class MyWidget extends StatefulWidget { | |
| @override | |
| _MyWidgetState createState() => _MyWidgetState(); | |
| } | |
| class _MyWidgetState extends State<MyWidget> { | |
| Widget buttonIcon; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| buttonIcon = Icon( | |
| Icons.attachment, | |
| size: 25, | |
| ); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Container( | |
| child: Column( | |
| mainAxisAlignment: MainAxisAlignment.start, | |
| children: <Widget>[ | |
| Container( | |
| padding: EdgeInsets.all(0), | |
| height: 200, | |
| width: 120, | |
| decoration: BoxDecoration( | |
| border: Border.all(color: Colors.black, width: 1), | |
| borderRadius: BorderRadius.circular(1), | |
| ), | |
| child: Transform.rotate( | |
| angle: math.pi / 4, | |
| child: IconButton( | |
| icon: buttonIcon, | |
| tooltip: 'Attachment', | |
| onPressed: () => setState(() => buttonIcon = Image.network( | |
| 'https://geeksta.net/img/large/tux-linux-hope-poster.jpg')), | |
| ) | |
| // child: showImage(), | |
| ), | |
| ), | |
| ])); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment