Skip to content

Instantly share code, notes, and snippets.

@stegrams
Created April 20, 2020 16:05
Show Gist options
  • Select an option

  • Save stegrams/7d70597fea5ce9e2db2d62638bf329ad to your computer and use it in GitHub Desktop.

Select an option

Save stegrams/7d70597fea5ce9e2db2d62638bf329ad to your computer and use it in GitHub Desktop.
Fetch an image from the web with a tap on a placeholder.
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