Skip to content

Instantly share code, notes, and snippets.

View pmatatias's full-sized avatar
🎯
Fluttering

Matatias Situmorang (Petra) pmatatias

🎯
Fluttering
View GitHub Profile
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
@pmatatias
pmatatias / blinkingwidget.dart
Created August 16, 2023 07:59
opacity blinking
///
/// pmatatias
///
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
import 'package:flutter/material.dart';
import 'dart:math';
Future<String> apiCall() async {
print("apiCall is executed...");
await Future.delayed(const Duration(seconds: 3));
return Future.value("${Random().nextInt(100)} update");
}
void main() => runApp(MyApp());