Я смотрю на этот шаблон, который я нашел на startflutter.com, и полный код можно увидеть ниже
Я пытаюсь вставить свое собственное изображение в круг, и кажется, что нет способа уместить изображение, чтобы оно полностью поместилось в рамку (оно всегда обрезается)
@override
Widget build(BuildContext context) {
final alucard = Hero(
tag: 'hero',
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircleAvatar(
radius: 72.0,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage('assets/alucard.jpg'),
),
),
);
Я бы хотел вставить изображение в контейнер, вот так
@override
Widget build(BuildContext context) {
final alucard = Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage("images/logo.png"),
fit: BoxFit.fill,
)
)
);
Но это не работает и не появится, что с этим не так?
Вот вся страница кода ...
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
static String tag = 'home-page';
@override
Widget build(BuildContext context) {
final alucard = Hero(
tag: 'hero',
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircleAvatar(
radius: 72.0,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage('assets/alucard.jpg'),
),
),
);
final welcome = Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Welcome Alucard',
style: TextStyle(fontSize: 28.0, color: Colors.white),
),
);
final lorem = Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec hendrerit condimentum mauris id ',
style: TextStyle(fontSize: 16.0, color: Colors.white),
),
);
final body = Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(28.0),
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Colors.blue,
Colors.lightBlueAccent,
]),
),
child: Column(
children: <Widget>[alucard, welcome, lorem],
),
);
return Scaffold(
body: body,
);
}
}