Я задаю этот вопрос после прохождения ТАКОГО вопроса.
Я перепробовал много ответов. Но ни один из них не работает для меня !!
Большинство вопросов в SO используют MaterialApp, но я возвращаю нормальный класс Material bcoz. Я не хочу Actionbar или что-то в этом роде.
Чего я пытаюсь достичь?
Я пытаюсь создать простой экран входа в систему, где значок приложения находится сверху, а затем имя пользователя, пароль и кнопка входа следуют за значком приложения.
Но увы! Значок приложения не загружается в AssetImage.
Ниже мой код
class Login extends StatelessWidget{
@override
Widget build(BuildContext context) {
return new Material(
color: Color.fromARGB(255, 0, 68, 178),
child: new Container(
margin: const EdgeInsets.all(5.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
//This will have Login EditTexts....
children: <Widget>[
//Adding Logo on Login Screen....
//NOT WORKING
// new DecoratedBox(
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage("assets/app_logo.jpg")
// )
// ),
// ),
//NOT WORKING
// new ImageIcon(
// new AssetImage("assests/app_logo.jpg"),
// size: 24.0,
// color: Colors.white,
// ),
//NOT WORKING
// new Container(
// decoration: new BoxDecoration(
// image: new DecorationImage(
// colorFilter: new ColorFilter.mode(
// Colors.black.withOpacity(0.6),
// BlendMode.dstATop
// ),
// image: new AssetImage("assets/applogo.jpg"),
// fit: BoxFit.contain
// )
// )
// ),
//NOT WORKING
// new Image.asset(
// 'assets/applogo.jpg',
// height: 60.0,
// fit: BoxFit.cover,
// ),
//NOT WORKING
new Directionality(
textDirection:TextDirection.ltr,
child: new Image.asset(
"assets/applogo.jpg",
height: 100.0,
width: 100.0,
fit: BoxFit.contain
)
),
//WORKING
new Text("Lets Login....", textDirection: TextDirection.ltr),
//WORKING
//Username TextField goes below....
new Directionality(
textDirection: TextDirection.ltr,
child: new TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Enter Username:'
),
)
),
//WORKING
//Password TextField goes below......
new Directionality(
textDirection:TextDirection.ltr,
child: new TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText:"Enter Password:"
)
)
),
//WORKING
//Login Button with Inkwell goes below....
new Directionality(
textDirection:TextDirection.ltr,
child: new InkWell(
child : new RaisedButton(
padding: const EdgeInsets.all(8.0),
textColor: Colors.white,
color: Colors.blue,
onPressed: login,
child: new Text("Login", textAlign: TextAlign.center, textDirection: TextDirection.ltr)
)
)
)
],
),//child Column closes here...
),//Container closes here.....
);//return Material closes here....
}//build closes here.....
void login(){
print("Login Pressed...");
}//login closes here....
}//Login class closes here....
Ниже мой pubspec.yaml
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/
- assets/app_logo.jpg