Skip to content

Instantly share code, notes, and snippets.

View iamEtornam's full-sized avatar
:octocat:
Focusing

Bright Etornam Sunu iamEtornam

:octocat:
Focusing
View GitHub Profile
@iamEtornam
iamEtornam / dropdown_example.dart
Created April 1, 2019 09:52
example of dropdownbutton in flutter
DropdownButton(
iconSize: 45.0,
items: <String>[
'MTN',
'TIGO',
'AIRTEL'].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
@iamEtornam
iamEtornam / AndroidManifest.xml
Created July 13, 2019 18:55
Solving SSL Permission Error in Android WebView
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
//add Internet permission
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
@iamEtornam
iamEtornam / Profile.dart
Created August 29, 2019 16:52
adding blurred background with image in flutter
import 'dart:ui';
import 'package:flutter/material.dart';
class ProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: ListView(
children: <Widget>[
@iamEtornam
iamEtornam / custom_popup_menu.dart
Last active October 31, 2020 18:16
sample code to create Android-like dropdown menu in flutter
import 'package:flutter/material.dart';
class CustomPopupMenu {
CustomPopupMenu({this.title, this.icon});
String title;
IconData icon;
}
@iamEtornam
iamEtornam / login_model.dart
Created November 19, 2019 11:06
using Provider for Authentication in Flutter
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:meler/repositories/user.repository.dart';
class LoginModel with ChangeNotifier {
TextEditingController _emailCtrl = TextEditingController();
TextEditingController _passwordCtrl = TextEditingController();
bool _isLoading = false;
@iamEtornam
iamEtornam / imageUploder.dart
Last active July 6, 2020 15:25
a simple function for uploading image to a server and returning a link to that image in dart/flutter
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
import 'package:path/path.dart';
Future<http.Response> imageUploadRequest({@required File imageFile}) async {
Map<String, String> headers = {"Accept": "application/json"};
Scaffold(
appBar: AppBar(
title: AutoSizeText('Doctors List'),
bottom: PreferredSize(child: Row(children: <Widget>[
customButton((){},Icons.filter,'Filter'),
customButton((){},Icons.filter,'Filter'),
customButton((){},Icons.filter,'Filter'),
],), preferredSize: Size.fromHeight(70)),
)
);
@iamEtornam
iamEtornam / fromHex.dart
Created January 20, 2020 15:03
converts color code to Hex color code
```dart
import 'package:flutter/material.dart';
Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}
```dart
//add to pubspec: material_segmented_control: ^2.0.9
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:material_segmented_control/material_segmented_control.dart';
class TeamDashboardPage extends StatefulWidget {
@iamEtornam
iamEtornam / main.dart
Created June 11, 2020 19:13
sample code on how to use flutter date picker
```dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {