Skip to content

Instantly share code, notes, and snippets.

View ponnamkarthik's full-sized avatar

Karthik Ponnam ponnamkarthik

View GitHub Profile
@ponnamkarthik
ponnamkarthik / custom_toggle.dart
Created June 8, 2021 05:22
Flutter Widget for toggle bar
import 'package:flutter/material.dart';
class CustomToggle extends StatefulWidget {
const CustomToggle({this.activeIndex = 1, @required this.items, this.onChanged});
final int activeIndex;
final List<String> items;
final Function(int) onChanged;
@ponnamkarthik
ponnamkarthik / gen_pdf.py
Last active September 28, 2021 15:51
Generate PDF From Url using Headless Browser pyppeteer
import asyncio
from pyppeteer import launch
async def main():
browser = await launch({ "headless": True, "ignoreHTTPSErrors": True, "dumpio": True })
page = await browser.newPage()
await page.goto('home_url', {"waitUntil": "networkidle0"})
await page.evaluate('''() => {
localStorage.setItem('accessToken', 'token');
@ponnamkarthik
ponnamkarthik / MultiSelectChoiceChipWithMaxSelection.dart
Created November 26, 2021 06:31
Flutter Multi-select ChoiceChip with max selection
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@ponnamkarthik
ponnamkarthik / viewbound_error.dart
Created December 4, 2021 03:22
Vertical viewport was given unbounded height.
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: ListView(
children: const [
Text("hello user")
],
),
@ponnamkarthik
ponnamkarthik / viewbound_error_solution_column.dart
Last active December 13, 2021 06:34
Vertical viewport was given unbounded height.
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
children: const [
Text("hello user")
],
),
@ponnamkarthik
ponnamkarthik / viewbound_error_solution_shrinkwrap.dart
Created December 4, 2021 03:43
Vertical viewport was given unbounded height.
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: ListView(
shrinkWrap: true,
children: const [
Text("hello user")
],
@ponnamkarthik
ponnamkarthik / viewbound_error_solution_customscrollview.dart
Created December 4, 2021 03:53
Vertical viewport was given unbounded height.
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: CustomScrollView(
slivers: [
SliverList(delegate: SliverChildBuilderDelegate(
(context, index) {
return Text("hello user");
},
@ponnamkarthik
ponnamkarthik / ShareSheet.swift
Created October 1, 2022 11:20
ios UIApplication extension function to get the UIViewController in flutter plugin
var sharedItems : Array<NSObject> = Array()
sharedItems.append((message as NSObject?)!)
let activityViewController = UIActivityViewController(activityItems: sharedItems, applicationActivities: nil)
activityViewController.setValue("Share", forKeyPath: "subject");
DispatchQueue.main.async {
UIApplication.topViewController()?.present(activityViewController, animated: true, completion: nil)
Paint paint = Paint()
..shader = Shader.linearGradient(
colors: [Colors.red, Colors.blue],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
CustomPaint(
painter: MyPainter(paint),
child: Container(),
);