Skip to content

Instantly share code, notes, and snippets.

View kmmraj's full-sized avatar

Mohanraj kmmraj

  • Bengaluru
View GitHub Profile
class RepoListActivity : AppCompatActivity(),
AdapterView.OnItemClickListener,
StoreSubscriber<RepoListState>
{
private var flutterIntent: Intent? = null
companion object {
const val REPO_DETAILS_CHANNEL = "repoInfo/details"
}
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
class AppController : Application() {
lateinit var engine: FlutterEngine
override fun onCreate() {
super.onCreate()
// Instantiate a FlutterEngine.
engine = FlutterEngine(this)
class RepoDetailModel extends ChangeNotifier {
int _forks = 1;
int _stargazers = 1;
String _languages = "";
String _title = "";
String _description = "";
bool favorite = false;
int get forks => _forks;
int get stargazers => _stargazers;
final _repoDetailMethodChannel = const MethodChannel('repoInfo/details');
RepoDetailModel() {
_repoDetailMethodChannel.setMethodCallHandler(_handleMethod);
}
import io.flutter.embedding.android.FlutterActivity
var repoDetailsChannelMethod : MethodChannel? = null
private fun startRepoDetailsActivity( position: Int) {
val repoDetailsData = toRepoDetailsDataJSON(position)
flutterIntent = FlutterActivity
.withCachedEngine("my_engine_id")
.build(this)
startActivity(flutterIntent)
repoDetailsChannelMethod?.invokeMethod("dataToDetailFlutterComponent", repoDetailsData)
}
channel.setMethodCallHandler { methodCall, result ->
when (methodCall.method){
"handleMessageBack" -> {
this.onBackPressed()
}
else -> { // Do something else
}
}
}
platform.invokeMethod("handleMessageBack", "Hi from Flutter");
Future<dynamic> _handleMethod(MethodCall call) async {
switch(call.method) {
case "message": {
print('Recieved data looks like ${call.arguments}');
setState(() {
// do set state
});
return new Future.value("");
}
}
static const platform = const MethodChannel('repoInfo/details');
@override
void initState() {
platform.setMethodCallHandler(_handleMethod);
super.initState();
}