Created
November 30, 2019 17:25
-
-
Save abdulazizahwan/fe6033949727322f02d9fc21f167fc78 to your computer and use it in GitHub Desktop.
Main.dart file of Flutter Tutorial - 17 Image Widget | Importing Image from an Assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
var assetImage =AssetImage('assets/dribbble_16.png'); | |
var image = Image( | |
image: assetImage, fit: BoxFit.cover, | |
); | |
void main(){ | |
runApp(MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: "My First Page", | |
home: FirstPage(), | |
)); | |
} | |
class FirstPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Home'), | |
backgroundColor: Colors.black, | |
leading: IconButton(icon: Icon(Icons.menu), | |
onPressed: (){ | |
print("Leading Clicked"); | |
},), | |
actions: <Widget>[ | |
IconButton(icon: Icon(Icons.notifications_none), | |
onPressed: (){ | |
print("Notification Clicked"); | |
},), | |
IconButton(icon: Icon(Icons.search), | |
onPressed: (){ | |
print("Search Clicked"); | |
},), | |
], | |
elevation: 6, | |
titleSpacing: 12, | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.add), | |
onPressed: (){ | |
print("FAB Clicked"); | |
}, | |
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))), | |
elevation: 5, | |
highlightElevation: 10, | |
), | |
body: Center(child: Container(height: 300, | |
width: 300, | |
alignment: Alignment(0.9, -0.98), | |
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),image: DecorationImage( | |
image: AssetImage('assets/dribbble_16.png'))))) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment