Skip to content

Instantly share code, notes, and snippets.

@nicowernli
Created December 11, 2019 12:27
Show Gist options
  • Save nicowernli/b776104e9c58da4b267ba0ab299a6b15 to your computer and use it in GitHub Desktop.
Save nicowernli/b776104e9c58da4b267ba0ab299a6b15 to your computer and use it in GitHub Desktop.
Flutter AppConfig for differente flavors
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
class AppConfig extends InheritedWidget {
AppConfig({
@required this.flavorName,
@required this.apiBaseUrl,
@required Widget child,
}) : super(child: child);
final String flavorName;
final String apiBaseUrl;
static AppConfig of(BuildContext context) {
return context.inheritFromWidgetOfExactType(AppConfig);
}
@override
bool updateShouldNotify(InheritedWidget oldWidget) => false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment