You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class AsGridImageView extends StatelessWidget {
|
|
final List<File>? files;
|
|
final List<String>? nets;
|
|
final String? placeholder;
|
|
|
|
const AsGridImageView.fromFile(
|
|
{Key? key, required this.files, this.placeholder})
|
|
: nets = null,
|
|
super(key: key);
|
|
|
|
const AsGridImageView.fromNets(
|
|
{Key? key, required this.nets, this.placeholder})
|
|
: files = null,
|
|
super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GridView(
|
|
padding: EdgeInsets.all(10.w),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 3,
|
|
mainAxisSpacing: 10.w,
|
|
crossAxisSpacing: 10.w,
|
|
),
|
|
shrinkWrap: true,
|
|
children: files == null
|
|
? nets!
|
|
.map((e) => FadeInImage.assetNetwork(
|
|
placeholder: placeholder ?? '', image: e))
|
|
.toList()
|
|
: files!.map((e) => Image.file(e)).toList());
|
|
}
|
|
}
|