Skip to content

Instantly share code, notes, and snippets.

View pmatatias's full-sized avatar
🎯
Fluttering

Matatias Situmorang (Petra) pmatatias

🎯
Fluttering
View GitHub Profile
@pmatatias
pmatatias / web_iframe_handler.dart
Last active July 31, 2024 06:49
preview iframe in flutter web
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'dart:ui_web' as ui;
import 'package:flutter/material.dart';
class WebIframeHanlder extends StatefulWidget {
final String source;
const WebIframeHanlder({super.key, required this.source});
@pmatatias
pmatatias / android_webview_handler.dart
Last active August 1, 2024 04:18
open camera from webview for android in flutter app
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:image_picker/image_picker.dart' as image_picker;
// ignore: depend_on_referenced_packages
import 'package:webview_flutter_android/webview_flutter_android.dart'
as webview_flutter_android;
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
@immutable
class UserProfile {
final String name;
final List<String> friends;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class UserProfile {
String name;
List<String> friends;

Mutable Class https://gist.github.com/pmatatias/a87bc52f1c766780270d7653e0428cee

  • Non-final Variables: In a mutable class, variables are not declared as final. This allows their values to be changed directly after the object's creation.

  • Direct State Manipulation: You can modify these variables directly from anywhere in the app, including the UI. For example, calling friendList.removeLast directly modifies the internal state of the object.

  • Potential Issue: The risk here is that if you change the state directly without properly notifying the UI (like using notifyListeners() in Flutter), the UI might not update to reflect this change. This can lead to inconsistencies and hard-to-track bugs, especially in more complex applications.

import 'package:flutter/material.dart';
void main() {
runApp(const FigmaToCodeApp());
}
// Generated by: https://www.figma.com/community/plugin/842128343887142055/
class FigmaToCodeApp extends StatelessWidget {
const FigmaToCodeApp({super.key});
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override