Flutter Dart - goatandsheep/goatandsheep.github.com GitHub Wiki
Flutter is a framework that uses a UI rendering library called Skia for building mobile apps built with the language Dart. It does not compile to mobile app components, but rather its own components.
Dependencies are in pubspec.yaml
Part or generator files or type generics: file.g.dart
/// class declaration
class Person {
String name;
// constructor
Person({String inputName}){
this.name = inputName;
}
}
class:
- with(mixin class): abstract class for reuse)
- extends(class): inheritance
- implements(interface);
null safety: value ?? fallback_value
interface:
- extends(interface):
State management Options: https://docs.flutter.dev/development/data-and-backend/state-mgmt/options
- Provider
- Riverpod (Provider rewrite)
- Bloc (state)
- getX
Accessibility: $ flutter run -d chrome --profile \ --dart-define=FLUTTER_WEB_DEBUG_SHOW_SEMANTICS=true
Android
flutter clean && flutter build appbundle --flavor prod --release
Future
use late to identify variables being initialized later but need to have a different scope
Whenever using map, if you don't assign the map to a value, it does not iterate properly.
Provider
Consumers use state data and rerun the children every time the set providers change
Consumers can watch multiple providers, such as Consumer2<Provider1, Provider2>(context, provider1, provider2, child) {})
Selectors only rerun when very specific parts of a provider change
You cannot get the width of components during build. If you need to compute something based on size, such as scrolling a specific amount, use WidgetsBinding.instance!.addPostFrameCallback((timestamp) {})