flutter image asset
// pubspec.yaml
flutter:
assets:
- graphics/
// Inside your widget
Image(image: AssetImage('graphics/background.png'))
flutter image asset
// pubspec.yaml
flutter:
assets:
- graphics/
// Inside your widget
Image(image: AssetImage('graphics/background.png'))
image from assets in flutter
Widget build(BuildContext context) {
return Image(image: AssetImage('graphics/background.png'));
}
flutter image assets
assets:
- lib/assets/images/
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');
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us