This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppController : Application() { | |
lateinit var engine: FlutterEngine | |
override fun onCreate() { | |
super.onCreate() | |
// Instantiate a FlutterEngine. | |
engine = FlutterEngine(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final _repoDetailMethodChannel = const MethodChannel('repoInfo/details'); | |
RepoDetailModel() { | |
_repoDetailMethodChannel.setMethodCallHandler(_handleMethod); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.flutter.embedding.android.FlutterActivity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
channel.setMethodCallHandler { methodCall, result -> | |
when (methodCall.method){ | |
"handleMessageBack" -> { | |
this.onBackPressed() | |
} | |
else -> { // Do something else | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platform.invokeMethod("handleMessageBack", "Hi from Flutter"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const platform = const MethodChannel('repoInfo/details'); | |
@override | |
void initState() { | |
platform.setMethodCallHandler(_handleMethod); | |
super.initState(); | |
} | |
NewerOlder