Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Unsplash random image instead of icon in Melody Card #17

Closed
ariessa opened this issue May 20, 2021 · 0 comments
Closed

Use Unsplash random image instead of icon in Melody Card #17

ariessa opened this issue May 20, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request wontenhance This will not be enhanced

Comments

@ariessa
Copy link
Owner

ariessa commented May 20, 2021

Problem

Description

Alternatives

Additional context

Possible Implementation

import 'package:flutter/material.dart';


void main() => runApp(RandomImg());


class RandomImg extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Random Images',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomeScreen(),
    );
  }
}


class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}


class _HomeScreenState extends State<HomeScreen> {
  int counter = 0;
  var _imageurl = 'https://source.unsplash.com/random/';


  Widget imageprovider() {
    return Image.network(
      _imageurl,
      fit: BoxFit.cover,
      height: double.infinity,
      width: double.infinity,
    );
  }


  void _newImage() {
    setState(() {
      _imageurl = 'https://source.unsplash.com/random/$counter';
      counter++;
    });
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Center(
          child: GestureDetector(
            child: imageprovider(),
            onTap: _newImage,
          ),
        ),
      ),
    );
  }
}
@ariessa ariessa added the enhancement New feature or request label May 20, 2021
@ariessa ariessa self-assigned this May 20, 2021
@ariessa ariessa closed this as completed May 22, 2021
@ariessa ariessa added the wontenhance This will not be enhanced label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontenhance This will not be enhanced
Projects
None yet
Development

No branches or pull requests

1 participant