yc_plugin_learn 0.0.1 copy "yc_plugin_learn: ^0.0.1" to clipboard
yc_plugin_learn: ^0.0.1 copied to clipboard

outdated

该组件提供了一种原生加载图片返回数据组flutter

example/lib/main.dart

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:yc_plugin_learn/yc_plugin_learn.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  var _data = null;

  @override
  void initState() {
    super.initState();
    initPlatformState();
    initData();
  }

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion =
          await YcPluginLearn.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;
    setState(() {
      _platformVersion = platformVersion;
    });
  }

  //加载图片数据
  initData() async {
    _data = await YcPluginLearn.getImage(
        "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F052420110515%2F200524110515-2-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1653472637&t=0a02c0594866f17f15d29a4753161f6e");
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(children: [
            Text('Running on: $_platformVersion\n'),
            _data == null ? Container(
              color: Colors.grey, width: 100, height: 100,) : Image.memory(
              _data, width: 100, height: 100, fit: BoxFit.cover,)
          ],),
        ),
      ),
    );
  }
}
0
likes
0
points
51
downloads

Publisher

unverified uploader

Weekly Downloads

该组件提供了一种原生加载图片返回数据组flutter

Homepage
Repository

License

unknown (license)

Dependencies

flutter

More

Packages that depend on yc_plugin_learn

Packages that implement yc_plugin_learn