Android
android development
app development
dart language
development
flutter admin dashboard
flutter development
flutter responsive
ios development
Create a Responsive Admin Template for Flutter
Flutter is an open-source UI software development kit created by Google that lets you create Android/iOS apps, as well as Web applications. If you want to create a web application, Flutter already offers some starter apps, however its source code is not actually easy to follow for beginners. Well, I wanted to use the Responsive Layout Starter app, but to use it I had to major code refactoring, which was a letdown. That's why I decided to create a Responsive Admin Template for Flutter
Overview
The design selected for the template is the Gentelella Admin Dashboard Template by ColorlibHQ:
I settled for this design because is the one I always use for my Symfony projects for its clean design, and also because I already made a port for the elgg framework. Yeah, I really like this design.
Getting Started:
1. Start Visual Studio Code. Go to menu “View -> Command Palette” and select the “Flutter: New Project” option:
2. Open the main.dart file, remove everything and use this code:
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'; | |
import 'package:gentelella_flutter/apps/home.dart'; | |
void main() => runApp(GentelellaAdmin()); |
4. Open the home.dart file. We will define the AppBar background color, the text color, and also we will be defining the home content, which will see soon:
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'; | |
import 'package:gentelella_flutter/widgets/ui/dashboard.dart'; | |
class GentelellaAdmin extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Gentelella Flutter Template', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
fontFamily: 'Quicksand', | |
//primarySwatch: Colors.purple, | |
appBarTheme: AppBarTheme( | |
color: Color(0xffEDEDED), | |
), | |
primaryTextTheme: TextTheme( | |
title: TextStyle( | |
color: Color(0xff73879C), | |
fontWeight: FontWeight.bold, | |
), | |
) | |
), | |
home: DashboardWidget(), | |
); | |
} | |
} |
6. Inside the ui folder, create a dashboard.dart file. Create a stateful widget, and create two variables:
_currentPage: An int variable that will hold the page index
_pages: List widget variable which will hold the pages of the app (Homepage() and ReceiptForm())
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
class DashboardWidget extends StatefulWidget { | |
@override | |
_DashboardWidgetState createState() => _DashboardWidgetState(); | |
} | |
class _DashboardWidgetState extends State<DashboardWidget> { | |
int _currentPage = 0; | |
final List<Widget> _pages = [ | |
HomePage(), | |
ReceiptForm(), | |
]; |
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
return Row( | |
children: <Widget>[ | |
Container( | |
), | |
Expanded( | |
child: Scaffold( | |
), | |
), | |
] | |
), |
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
Expanded( | |
child: Scaffold( | |
appBar: AppBar( | |
automaticallyImplyLeading: | |
MediaQuery.of(context).size.width < 600, | |
title: Text('Gentelella Dashboard Template'), | |
actions: <Widget>[IconButton( | |
icon: const Icon(Icons.exit_to_app, color: Color(0xff2A3F54),), | |
tooltip: 'Logout', | |
onPressed: () { | |
}, | |
),], | |
), | |
body: _pages[_currentPage], | |
), | |
), |
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'; | |
import 'package:gentelella_flutter/api/users_list_api.dart'; | |
import 'package:gentelella_flutter/models/users.dart'; | |
import 'dart:async'; | |
import 'dart:convert'; | |
class HomePage extends StatefulWidget { | |
// name({Key key}) : super(key: key); | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: SingleChildScrollView(child: Column( | |
children: <Widget>[ | |
SizedBox(height: 10,), | |
Text('Homepage'), | |
SizedBox(height: 50,) | |
], | |
), | |
), | |
); | |
} | |
} |
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'; | |
import 'package:gentelella_flutter/widgets/forms/add_new_user.dart'; | |
class ReceiptForm extends StatefulWidget { | |
ReceiptForm({Key key}) : super(key: key); | |
@override | |
_ReceiptFormState createState() => _ReceiptFormState(); | |
} | |
class _ReceiptFormState extends State<ReceiptForm> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: SingleChildScrollView( | |
child: | |
Column( | |
children: <Widget>[ | |
Text('Add users page'), | |
], | |
),), | |
); | |
} | |
} |
Grab the source code here: Gentelella Flutter
You can also see it in action here: Flutter Responsive Demo
No comments
Post a Comment