Answers for "flutter show get image"

4

image from internet flutter

Image.network(
  'https://picsum.photos/250?image=9',
)
Posted by: Guest on August-01-2020
2

flutter get image file from assets

import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart' show rootBundle;
import 'package:path_provider/path_provider.dart';

Future<File> getImageFileFromAssets(String path) async {
  final byteData = await rootBundle.load('assets/$path');

  final file = File('${(await getTemporaryDirectory()).path}/$path');
  await file.writeAsBytes(byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));

  return file;
}

File f = await getImageFileFromAssets('images/myImage.jpg');
Posted by: Guest on April-27-2021

Code answers related to "flutter show get image"

Code answers related to "Dart"

Browse Popular Code Answers by Language