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

A new Flutter package project.

example/lib/main.dart

import 'package:example/clip_image_page.dart';
import 'package:flutter/material.dart';

import 'rounded_image_page.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      showPerformanceOverlay: true,
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: PerformanceListPage(),
    );
  }
}

class ListTileInfo {
  final String title;
  final VoidCallback tapAction;
  final String subTitle;

  ListTileInfo({this.title, this.tapAction, this.subTitle});
}

class PerformanceListPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final List<ListTileInfo> itemList = [
      ListTileInfo(
          title: '裁剪圆角',
          subTitle: '通过ClipRRect显示圆角',
          tapAction: () {
            Navigator.push(context, MaterialPageRoute(builder: (_) => ClipImagePage()));
          }),
      ListTileInfo(
          title: '图片生成圆角',
          subTitle: '图片生成圆角再显示',
          tapAction: () {
            Navigator.push(context, MaterialPageRoute(builder: (_) => RoundedImagePage()));
          }),
    ];
    return Scaffold(
      appBar: AppBar(
        title: Text('裁剪圆角和生成圆角图片对比'),
      ),
      body: ListView.separated(
        itemBuilder: (_, index) {
          ListTileInfo info = itemList[index];
          return GestureDetector(
            onTap: info.tapAction,
            child: ListTile(
              title: Text(info.title),
              subtitle: info.subTitle != null ? Text(info.subTitle) : null,
            ),
          );
        },
        separatorBuilder: (_, __) => Divider(
          height: 1,
        ),
        itemCount: itemList.length,
      ),
    );
  }
}